Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Enterprise
Expertise: Beginner
Oct 21, 2002

Insert Explicit Values into the Identity Column of a Table


For inserting explicit values into the identity column of a table, IDENTITY_INSERT property is set to ON.
 
Table tblName has got following fields
CompanyID INT IDENTITY(1,1)
CoName VARCHAR(75)

And following the data:
 
CompanyID	CoName
1		Starcraft Corporation
2		Holobeam Inc
3		OnSpan Networking Inc
4		CaminoSoft Corp.
5		OMNI Rail Products Inc

Inserting rows with explicit value for CompanyID

SET IDENTITY_INSERT tblName ON

INSERT INTO tblName(CompanyID,CoName) 
VALUES(10,' Globix Corporation')
INSERT INTO tblName(CompanyID,CoName) 
VALUES(6,'Teltone Corp')

After these insertions, the current identity value for the table tblName will be 10.
Ajit Kumar
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date