sql - How to insert a new record in a table by MAX(ID) + 1 of the same table -


I have a table CMT_M_DISPOSITION (DispositionKey, DispositionValue) . On pk DispositionKey I want to insert a new record by using MAX (DispositionKey) + 1 for the first column.

I get an error

Invalid column DispositionKey

When I run the code below.

Can anyone explain the reason that I am getting this error and how to solve it? set_inertert_Enter_Enter_Enter_Enter_Enter_Enter_Enter_Enter_Enter_Enter_Enter_Enter_Enter_Entertension_inertEystem_inertEY_CMT_TestV2..CMT_M_DISPOSITION (DispositionKey, DispositionValue) Value (Max DispositionKey + 1, 'Latest') Setting identity_insert EY_CMT_TestV2..CMT_M_DISPOSITION off / pre>

  SET IDENTITY_INSERT insert the CMT_M_DISPOSITION on EY_CMT_TestV2..CMT_M_DISPOSITION (DispositionKey, DispositionValue) Max (DispositionKey ) + select 1, CMT_M_DISPOSITION SET IDENTITY_INSERT EY_CMT_TestV2..CMT_M_DISPOSITION from oFF    

insert identification (in this case, clearly value iNSERT defined iNTO ... Select) and therefore The need to be started before inserting allows clear values ​​to be included.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -