Ever have a table where you need to insert a value into an identity field.
For example - you may have a lookup table with values 2, 3, 4 - I don't know about you but it annoys me to no end when the 1 value is missing. You could truncate the table and re-insert all the values... but this is assuming there is no foreign keys...
Here is a way you can actually insert the Identity ID value:
[code language="T-SQL"]SET IDENTITY_INSERT membership.maritalstatus ON
INSERT membership.maritalstatus (MaritalStatusID,[Name]) VALUES(2, 'Married')
SET IDENTITY_INSERT membership.maritalstatus OFF
SELECT * FROM membership.maritalstatus[/code]
If you need to check the identity colum
[code language="T-SQL"]DBCC CHECKIDENT('membership.maritalstatus')
[/code]
If you need to reseed the identity column
[code language="T-SQL"]
DBCC CHECKIDENT('membership.maritalstatus', RESEED, 2)
Insert membership.maritalstatus ([name]) Values ('Married')[/code]