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, 2:56 AM EDT
Thanx brother for sharing the query
SubashPosted Aug 22, 2016, 6:40 PM EDT
Nice
Pankaj Kumar ChoudharyTOP 100Posted Apr 11, 2016, 9:00 AM EDT
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 RajamanickamTOP 100Posted Apr 10, 2016, 10:43 PM EDT
good one...
Rahul Kumar SaxenaTOP 100Posted Apr 10, 2016, 7:14 AM EDT
Thanks Michael Griffiths
Michael GriffithsPosted Apr 10, 2016, 6:10 AM EDT
Nice