Actually SQL 10.5 server, 10.0 SSMS
table is policies
Export all records with integer pk > 250 to the same database using query so there is a new table called Query hold just those records.
Delete all records with pk > 250
DBCC checkident
(policies, reseed, 251)
( check with noreseed and it is correct)
If inserting a new record from my app the pk is 251. So far so good. Delete that record and reseed.
Now import the records I had exported previously, allowing the creation of identity keys.
Records import fine, but the first pk is 252.
( to be clear, the problem below occurred before testing by inserting a record from my app, so it is not a failure to delete that record or properly reseed etc)
Do it all over and over again, one time even setting seed to 250. On import first record is still 252.
I am carefully reseeding and checking seed. App honors seed. Import skips one before starting.
Is this known behavior and is there a way around it? I suspect it has something to do with the import operation being set-based.
( bonus question : is there an easy way to increment or decrement the existing identity key in a table by 1 for all pks > 250 - assuming not violating uniqueness )
Have learned a lot so far in playing with this so hope to learn more.
TIA
Charles Hankey
Though a good deal is too strange to be believed, nothing is too strange to have happened.
- Thomas Hardy
Half the harm that is done in this world is due to people who want to feel important. They don't mean to do harm-- but the harm does not interest them. Or they do not see it, or they justify it because they are absorbed in the endless struggle to think well of themselves.
-- T. S. Eliot
Democracy is two wolves and a sheep voting on what to have for lunch.
Liberty is a well-armed sheep contesting the vote.
- Ben Franklin
Pardon him, Theodotus. He is a barbarian, and thinks that the customs of his tribe and island are the laws of nature.