identity - IDENTITY_INSERT ON not working - SQL Server 2008 R2 -


i having problems query. basically, trying empty out table , copy records same table in database.

i did use set identity_insert code make sure identity column turned off before perform insert. somehow, still throws me error message:

msg 8101, level 16, state 1, line 3
explicit value identity column in table 'dbo.ui_page' can specified when column list used , identity_insert on.

below query:

delete [db1].[dbo].[my_table]   set identity_insert [db1].[dbo].[my_table] on  insert [db1].[dbo].[my_table]    select *     [db2].[dbo].[my_table]  set  identity_insert [db1].[dbo].[my_table] off 

can point me step doing wrong?

thanks lot!

you have specify column names when inserting identity insert on when using insert into

insert  [db1].[dbo].[my_table](tabelid,field1,field2,field3...) select *  [db2].[dbo].[my_table] 

in case did not know there nifty little trick in ssms. if select table , expand its' nodes ctrl-c copy on columns node , place comma-delimited list of field names on clipboards text buffer.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -