Using SQL Server 2008 R2, I have a Users table, in which I would like to reserve the top 99 ID values for manual-entry system users. I have set my identity seed to 100, so that all new users will be given a value 100+ in normal behavior. I found that I can use SET IDENTITY_INSERT to suppress the identity specification and provide an explicit value for this column. What I need to know, and could not really understand from MSDN, is if this suppression will only apply to the context of the running script. (i.e., new users created on the site, calling the normal insert proc, will still be given autogenerated ID of next value > 100)
Using SQL Server 2008 R2, I have a Users table, in which I would
Share
SET IDENTITY_INSERTallows you to directly insert an identity value, it doesn’t require it. So, even if it were a shared setting, running your “normal” INSERT would get an auto-generated identity.That said, it is a per-session setting as well, so you’re doubly safe.
As to the design – I’ve done similar, and don’t see an issue with it. Having “well-known” identifiers is fairly common – though you’ll have to decide whether 100 is an appropriate block to reserve. Though possible, you really don’t want to have to open a non-contiguous block at a later time. I’ve used negative numbers in the past when there wasn’t a reserved range.