Manually Insert into Identity Column SQL Server


Example to manually insert into an identity column in a table in a MS SQL Server database:


SET IDENTITY_INSERT tblSellingPeriod ON
INSERT INTO tblSellingPeriod (SellingPeriod_Id, Description, Sort) Values (28,'Temp',21)

SET IDENTITY_INSERT tblSellingPeriod Off

(i.e. you have to fiddle with the IDENTITY_INSERT flag)


Some references:
 http://www.akadia.com/services/sqlsrv_programming.html
 http://www.experts-exchange.com/Databases/Q_21040806.html
Related Scribbles:
  • SQL Server


  • ID: 667
    Author:
    leonard
    Date Updated:
    2005-07-26 12:11:46
    Date Created:
    2005-07-26 12:10:56

    Edit

    Comments?
     >> Leonard Chan's Homepage  >> Scribble Web  >> Manually Insert into Identity Column SQL Server
    leonard.lotus-land.ca is hosted by Perceptus Solutions Inc.