Link to home
Start Free TrialLog in
Avatar of hefterr
hefterrFlag for United States of America

asked on

Adding a row keyed by an IDENTITY

Hi,
I have an integer key that is an IDENTITY starting at 100.  Can I INSERT a row and specify the identity key value if it's less than 100?  Can I ever specify the IDENTITY value in an INSERT?

Thanks,
hefterr
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

yes, you can, using the SET IDENTITY_INSERT syntax:
http://msdn.microsoft.com/en-us/library/ms188059.aspx
ASKER CERTIFIED SOLUTION
Avatar of chapmandew
chapmandew
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hefterr

ASKER

Hey Thanks.  One more question.  If I insert a row higher than the identity counter for my table, will that identity value be skipped ny SQL Server in the future or will I end up with a duplicate key situation?

Thanks again.
hefterr
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial