1 頁 (共 1 頁)

SQL Server: Update Existing Column Value in Serial Number

發表於 : 2019-09-16 16:47:02
yehlu
https://www.c-sharpcorner.com/blogs/sql ... ial-number

In this article I am going to show how we can update our existing column value with serial number without using loop. Below is my problem.

facebook
twitter
linkedIn
Reddit
expand
Download Free .NET & JAVA Files API
I have the below table in my SQL Server Data Base:

database

Table script:
CREATETABLE [dbo].[Employee_Rank](
[EmployeeName] [varchar](50)NULL,
[Rank] [int] NULL
)ON [PRIMARY]

GO
Data in Table:

table

Now my requirement is below:

requirement

So I wrote the below SQL Statement:

Statement
DECLARE @SRNO INT=0;
UPDATE EMPLOYEE_RANK SET @SRNO =RANK= @SRNO + 1

SELECT*FROM EMPLOYEE_RANK