I was running a small test on how WHILE loop fucntions.
this is a simple SQL code that I ran
declare @COUNTER int
set @COUNTER = 1
while @COUNTER <= 100000
begin
select @COUNTER = @COUNTER + 1
end
It took 7 seconds to run
I ran the C# equivalent which did not even take a second (fraction of second)
int counter = 1;
while (counter<= 100000)
{
counter += 1;
}
My question .... Is the WHILE in SQL Server so bad in comparison to C# one... or Am i doing smth wrong or Can I do smth to improve it...
this is a simple SQL code that I ran
declare @COUNTER int
set @COUNTER = 1
while @COUNTER <= 100000
begin
select @COUNTER = @COUNTER + 1
end
It took 7 seconds to run
I ran the C# equivalent which did not even take a second (fraction of second)
int counter = 1;
while (counter<= 100000)
{
counter += 1;
}
My question .... Is the WHILE in SQL Server so bad in comparison to C# one... or Am i doing smth wrong or Can I do smth to improve it...
Comment