Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
some sequential vales are deleted i want to use those values
Posted

1 solution

You can't, without disabling the identity temporarily - and what if you are in a multiuser environment? If two people decide to re-use the old number at the same time, you could be back with teh same problem you are trying to use identity fields to avoid....

If you need a number which reflects a rows position in the number of records, then use the ROW_NUMBER function:
SQL
SELECT Id, Customer, date, Value,
       @@ROWCOUNT as 'Row Count',
       ROW_NUMBER() OVER (ORDER BY Id) AS 'Row Number'
  FROM Customers
That will vary as you insert and remove records, but the identity value can remain safe and unique.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900