Tuesday, June 24, 2014

How to Insert Values into an Identity Column in SQL Server?

To insert values into an identity column, you have to first set identity_insert ON and after inserting or updating, you have to set it OFF like following:
SET IDENTITY_INSERT [dbo].[YourTableName] ON 
GO
INSERT INTO [dbo].[YourTableName]
           ([ID] 
           ,[Code]
           ,[Description]
           ,[Required_by_System] )
     VALUES
           (9
           ,900
           ,'Record Updated'
           ,'Y' )
GO
SET IDENTITY_INSERT [dbo].[YourTableName] OFF
GO

No comments:

Post a Comment

React-select is very slow on larger list - Found solution - using react-window

 I had more than 4000 items in searchable dropdownlist. I have used react-select but it was very slow. finally I found complete solution to ...