Monday, June 11, 2012

Explicitly insert data into identity column : Sql Server

To insert data into Identity Column
Set identity_insert table_name ON
Explicitly specify the column names of the table in which data is to be inserted
Set identity_insert table_name OFF

[code language="sql"]
set identity_insert table_name ON
insert into table_name(identity_column_name,second_column_name) values
(21, 'text 1'),
(23, 'text 2'),
(24, 'text 3')
set identity_insert table_name OFF
[/code]

No comments: