Re-Identity a Table in SQL Server



TODO:  Have you ever wanted to re-indentity a column in SQL Server?

 

SOLUTION

T-SQL

 

DECLARE @Count INT
SET @Count = 0

UPDATE [dbname].[dbo].[table]
SET  @Count = [id] = @Count+1

 

 

NOTES:

Identity Insert must be enabled.

"Id" is the name of the identity column.



Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading