Friday, 22 May 2020

While loop on table rows in sql server using cursor



DECLARE @RID INT;
 ---- get table rid inside CUR_TEST
DECLARE CUR_TEST CURSOR FAST_FORWARD FOR SELECT RID FROM  tbl_User_Registration

OPEN CUR_TEST
FETCH NEXT FROM CUR_TEST INTO @RID

WHILE @@FETCH_STATUS = 0
BEGIN
declare @EmdilID varchar(100)='test@gmail.com'

   UPDATE tbl_User_Registration SET emialid = @EmdilID WHERE RID = @RID;

   FETCH NEXT FROM CUR_TEST INTO @RID
END
CLOSE CUR_TEST
DEALLOCATE CUR_TEST
GO

No comments:

Post a Comment

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...