Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

IDENTITY_INSERT Expand / Collapse
Author
Message
Posted Friday, August 2, 2013 5:51 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 12:34 AM
Points: 1,888, Visits: 2,326
Hi, when I try this query it gives me an error
An explicit value for the identity column in table 'DC1..DMAuditHistory' can only be specified when a column list is used and IDENTITY_INSERT is ON.


DECLARE @projectId int
SELECT @projectId = ProjectId FROm Project with(nolocK) WHERE ProjectNo = '61N24643'

SET IDENTITY_INSERT DC1..DMAuditHistory ON
INSERT INTO DC1..DMAuditHistory SELECT * FROM DMAuditHistory with(nolock) WHERE ProjectId = @projectId
SET IDENTITY_INSERT DMAuditHistory OFF



_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1480342
Posted Friday, August 2, 2013 5:58 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 12:34 AM
Points: 1,888, Visits: 2,326
I have solved myself_

Changed the query to this--

DECLARE @projectId int
SELECT @projectId = ProjectId FROm Project with(nolocK) WHERE ProjectNo = '61N24643'

SET IDENTITY_INSERT DC1..DMAuditHistory ON
INSERT INTO DC1..DMAuditHistory (ProjectID,ProposalID,SolutionID,RequestID,AuditFieldTypeID,SrNo,Dateaudited,
AuditFieldvalue,DrawingStatus,CommerceId,DeleteFlag,AddedBy,DateAdded,ChangedBy,dateChanged,GlobalUniqueID)
SELECT * FROM DMAuditHistory with(nolock) WHERE ProjectId = @projectId
SET IDENTITY_INSERT DMAuditHistory OFF
GO




_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1480345
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse