@@rowcount is now working with while and if statement
-
I have created a sp in which i have used @@rowcount with while but it is not working e.g Select * from #temp print @@rowcount while @@rowcount <> 0 begin ---- ---- --- end the print command is giving rowcount 1 but still it is not working
One person's data is another person's program. --J.Walia
-
I have created a sp in which i have used @@rowcount with while but it is not working e.g Select * from #temp print @@rowcount while @@rowcount <> 0 begin ---- ---- --- end the print command is giving rowcount 1 but still it is not working
One person's data is another person's program. --J.Walia
Remove that
print @@rowcount
or declare a variable and set the @@rowcount into that variable and use that variable further.DECLARE @rc AS INTEGER
Select * from #temp
SET @rc = @@rowcount
print @rc
while @rc <> 0
begin
end
-
Remove that
print @@rowcount
or declare a variable and set the @@rowcount into that variable and use that variable further.DECLARE @rc AS INTEGER
Select * from #temp
SET @rc = @@rowcount
print @rc
while @rc <> 0
begin
end
This is because the @@ values get reset when an action (print) executes.