Saturday 14 June 2014

SQL Bulk Update Statement using WHILE loop

DECLARE @str varchar(100)
DECLARE @counter int
SET @counter = 1;
WHILE @counter < 1000
BEGIN
SET @str=Convert(Varchar(100),@counter)+'Test'
UPDATE dbo.MyTable
SET name =@str where ID=@counter
print @counter
print @str
SET @counter = @counter + 1
END