sql server - IDENTITY_INSERT issue with sql -


i trying populate azure database, when run query :

set identity_insert author on  declare @teaser varchar(4000) = 'text..'; declare @body varchar(4000) = 'text...';  insert author(id,first_name,last_name,email) values (1,'dan','vega','danvega@gmail.com'); insert author(id,first_name,last_name,email) values (2,'john','smith','johnsmith@gmail.com');  insert post(id,title,slug,teaser,body,author_id,posted_on) values (1,'spring boot rocks!','spring-boot-rocks',@teaser,@body,1,default); 

i have error on insert post line : cannot insert explicit value identity column in table 'post' when identity_insert set off. after run authors created not post.

if add both set identity_insert author on set identity_insert post on have identity_insert on table 'spring-boot-intro.dbo.author'. cannot perform set operation table 'post'. . if add set identity_insert post on have cannot insert explicit value identity column in table 'author' when identity_insert set off.

at time, 1 table in session can have identity_insert property set on.

from docs


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - VueJS2 and the Window Object - how to use? -