Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 explicit identity

Author  Topic 

keizy07
Starting Member

8 Posts

Posted - 2012-03-22 : 23:25:50

i need help in here the error is this Msg 545, Level 16, State 1, Line 10
Explicit value must be specified for identity column in table '#orderlisting_______________________________________________________________________________________________________000000000003' either when IDENTITY_INSERT is set to ON or when a replication user is inserting into a NOT FOR REPLICATION identity column.

Msg 544, Level 16, State 1, Line 18
Cannot insert explicit value for identity column in table '#orderlisting_______________________________________________________________________________________________________000000000003' when IDENTITY_INSERT is set to OFF.


how can i fix it tnx

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-22 : 23:33:15
sorry i didt understand what you're trying to do here.
seems like you want identity_insert to be done inside loop rather than outside

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

veeraC85
Starting Member

2 Posts

Posted - 2012-03-27 : 22:49:19
In your insert statement, you have to specify list of columns you are inserting into.

EXAMPLE: (EmployeeID is an identity column)

SET IDENTITY_INSERT dbo.TBLEMPLOYEE ON
GO
INSERT INTO dbo.TBLEMPLOYEE(EMPLOYEEID, EMPLOYEENAME, EMPLOYEESSN, EMPLOYEESTATE) VALUES(1, 'TEST' ,'TEST', 'TEST')
GO
SET IDENTITY_INSERT dbo.TBLEMPLOYEE OFF
GO

For more information and examples on Identity Columns, you could visit
[url]http://technico.qnownow.com/2012/03/27/identity-columns-in-sql-server/[/url]
Go to Top of Page
   

- Advertisement -