This question already has an answer here:
Why is the @@ROWCOUNT variable returning zero after the IF statement (1 answer)
Closed 23 days ago.
Here is my stored procedure
/****** Object: StoredProcedure [dbo].[TestStoProc] Script Date: 21.09.2023 13:32:40 ******/
ALTER PROCEDURE [dbo].[PurgeSyncOperations]
-- Parameters for the stored procedure here
@Date datetime,
@CustomerNumber nvarchar(10),
@count int = 0 output
AS
BEGIN
DECLARE @row INT;
SET @row = 1;
WHILE @row > 0
BEGIN
-- Statements for archiving and deletion
//some query to insert data
//some query to delete data
SET @row = @@ROWCOUNT;
SET @count = @count + @@ROWCOUNT
END
END
I am getting always zero from this stored procedure. Need help on this.
1条答案
按热度按时间ybzsozfc1#
assigns rowcount from the set @row = @@rowcount operation.
Surely you want: