SQL Server: Update Existing Column Value in Serial Number

I have the below table in my SQL Server Data Base:

database

Table script:

  1. CREATETABLE [dbo].[Employee_Rank](  
  2. [EmployeeName] [varchar](50)NULL,  
  3. [Rank] [intNULL  
  4. )ON [PRIMARY]  
  5.   
  6. GO 
Data in Table:

table

Now my requirement is below:

requirement

So I wrote the below SQL Statement:

Statement
  1. DECLARE @SRNO INT=0;  
  2. UPDATE EMPLOYEE_RANK SET @SRNO =RANK= @SRNO + 1  
  3.   
  4. SELECT*FROM EMPLOYEE_RANK   

 

Ebook Download
View all
Learn
View all