SQL Server - how to add a new data to a table

Asked By sanhita sinha on 19-Sep-06 04:56 AM
i have a table EMPLOYEE with attributes emp_id, emp_name

now i hv data in it with emp_id frm 1 to 9...

now say, i delete emp_id =3,

now whn i add a new entry.. i want my system to automatically gv the vacant id 3 and not 10...

can any1 help me wid the code???


use SET IDENTITY_INSERT ON

mv ark replied to sanhita sinha on 19-Sep-06 05:30 AM
If you want to insert a value into an identity column you can use the SET IDENTITY_INSERT statement.

SET IDENTITY_INSERT Yaks ON
Insert Yaks (YakID, YakName) Values(1, 'Mac the Yak')
SET IDENTITY_INSERT Yaks OFF
select * from yaks
Read more about IDENTITY here - http://www.sqlteam.com/item.asp?ItemID=8003