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

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

Now my requirement is below:

So I wrote the below SQL Statement:

- DECLARE @SRNO INT=0;
- UPDATE EMPLOYEE_RANK SET @SRNO =RANK= @SRNO + 1
- SELECT*FROM EMPLOYEE_RANK

pabitra beheraPosted Jun 14, 2020, 6:56 AM
Thanx brother for sharing the query
SubashPosted Aug 22, 2016, 10:40 PM
Nice
Pankaj Kumar ChoudharyPosted Apr 11, 2016, 1:00 PM
Hello Rahul Sir! I think there is little bit difference b/w your requirement and your result.. In your requirement Amit is 1 and in your result rank of Amit is 5, So can you check thatwhere is code wrong...... It is confusing me to find out the what is real requirement of this code.........
Gowtham RajamanickamPosted Apr 11, 2016, 2:43 AM
good one...
Rahul Kumar SaxenaPosted Apr 10, 2016, 11:14 AM
Thanks Michael Griffiths
Michael GriffithsPosted Apr 10, 2016, 10:10 AM
Nice