How to update sequence number for existing records - SQL Server

PandianS
Posted by PandianS under Sql Server category on | Points: 40 | Views : 4825
CREATE TABLE #Table1
(
Id INT NULL,
Column1 VARCHAR(50)
)
GO

INSERT #Table1(Column1) VALUES('Failover Clustering')
INSERT #Table1(Column1) VALUES('Mirroring')
INSERT #Table1(Column1) VALUES('Replication')
INSERT #Table1(Column1) VALUES('Log Shipping')
INSERT #Table1(Column1) VALUES('Database Snapshot')
INSERT #Table1(Column1) VALUES('Database Backup')
GO

DECLARE @Seq INT
SELECT @Seq = 0
UPDATE #Table1 SET Id = @Seq , @Seq = @Seq + 1
GO

SELECT * FROM #Table1
GO

DROP TABLE #Table1
GO

Comments or Responses

Login to post response