IDENTITY_INSERT is ON error

  • 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

  • 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]

  • 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 😀

  • thank you!! should i set it off at the end?

    SET IDENTITY_INSERT tblDistributors

    OFF

  • Yes, turn it back off when you are done.

  • 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