SET IDENTITY_INSERT ON




We have created a sample table in previous article of Identity column
Now we will look how to insert values explicitly in this tables

*All column names must be specified in insert statement
* set identity_insert off after completing insert


SET IDENTITY_INSERT <TABLE NAME> ON

SET IDENTITY_INSERT TEST ON

INSERT INTO test
            (id,
             value)
SELECT 10,
       'e'

INSERT INTO test
            (id,
             value)
SELECT 11,
       'f'

SET IDENTITY_INSERT TEST OFF

 
SELECT *
FROM   TEST








No comments:

Post a Comment

Amazon Contextual Product Ads

Popular Posts