April 21, 2008 at 1:23 pm
hi guys i am trying to do an insert
INSERT INTO tblDistributors
VALUES ('AlabamaZinc', 'PT', 'OUT-XCS', 'Inbound', '1','LS','1','2','0','2040','8999','0', '','0','0','1')
but i am getting this error
Msg 8101, Level 16, State 1, Line 1
An explicit value for the identity column in table 'tblDistributors' can only be specified when a column list is used and IDENTITY_INSERT is ON.
so i tried this
SET IDENTITY_INSERT tblDistributors
ON
INSERT INTO tblDistributors
VALUES ('AlabamaZinc', 'PT', 'OUT-XCS', 'Inbound', '1','LS','1','2','0','2040','8999','0', '','0','0','1')
SET IDENTITY_INSERT tblDistributors
OFF
but i keep getting the same error
April 21, 2008 at 1:36 pm
You are still not specifying a column list.
Your insert shoud look something like this:
[font="Courier New"]INSERT INTO tblDistributors (MyCol1, MyCol2, MyCol3...)
VALUES ('AlabamaZinc', 'PT', 'OUT-XCS', 'Inbound', '1','LS','1','2','0','2040','8999','0', '','0','0','1')[/font]
April 21, 2008 at 1:37 pm
Along with the IDENTITY_INSERT command you need to specify a column list
LIKE
INSERT INTO tblDistributors (Column1, Column2, ...etc)
Rats Should've typed faster 😀
April 21, 2008 at 1:39 pm
thank you!! should i set it off at the end?
SET IDENTITY_INSERT tblDistributors
OFF
April 21, 2008 at 1:45 pm
Yes, turn it back off when you are done.
April 21, 2008 at 1:50 pm
thank you!!!!!!:D
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply