Friday, 22 May 2020

While loop on table rows in sql server




DECLARE @CursorTestID INT = 1;
DECLARE @RowCnt BIGINT = 0;

-- get total count of rows to process
SELECT @RowCnt = COUNT(0) FROM tbl_User_Registration;

WHILE @CursorTestID <= @RowCnt
BEGIN
declare @StrBinary varchar(350)='abc12345'

   UPDATE tbl_User_Registration SET [Password] = @StrBinary WHERE [Password] is null;
   SET @CursorTestID = @CursorTestID + 1

END



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...