i am using below query to update my all records but it starts update from second row how can i modify it to do changes from 1'st row ?
i am using mssql 2008
i think i can not use @@FETCH_STATUS
as 1'st line as it is global.
thanks in advance
use vivdb
DECLARE @empno as int;
select @empno = 10;
DECLARE Employee_Cursor CURSOR FOR select * from emp
OPEN Employee_Cursor;
FETCH NEXT from Employee_Cursor
WHILE @@FETCH_STATUS = 0
BEGIN
update emp set empno = @empno;
select @empno = @empno+1;
FETCH NEXT from Employee_Cursor
END;
CLOSE Employee_Cursor;
DEALLOCATE Employee_Cursor;
GO