Guys I am trying to execute below insert statement and I keep getting the error:
cannot insert into a generated always identity column
the statement is :
INSERT INTO leaves_approval
SELECT *
FROM requests_temp r
WHERE r.civil_number = 33322
AND r.request_id = (SELECT Max(s.request_id)
FROM requests_temp s)
What don't you understand about the error? You have an "identity" column, where the value is generated as a sequence. You cannot insert into it. So, list all the other columns:
In general, it is a good idea to list all the columns in an
INSERTanyway. This prevents unexpected errors, because the columns are in the wrong order or the tables have different numbers of columns.