Пожалуйста, попробуйте это.
SET NOCOUNT ON;
DECLARE @rows INT, @count INT, @message VARCHAR(100);
SET @rows = 1;
SET @count = 0;
BEGIN TRY
BEGIN TRANSACTION;
WHILE @rows > 0
BEGIN
delete top(100000) from Table whete T1='HU'
SET @rows = @@ROWCOUNT;
SET @count = @count + @rows
RAISERROR('COUNT %d', 0, 1, @count) WITH NOWAIT
END
COMMIT TRANSACTION;
END TRY
BEGIN CATCH
ROLLBACK TRAN
END CATCH
------------- Например
Declare @tbl Table(
CustomerID INT ,
CustomerName VARCHAR(100),
AccreditationNumber VARCHAR(100)
)
INSERT INTO @tbl VALUES(1272,'Bree','Gold')
INSERT INTO @tbl VALUES(1272,'Bree','Gold')
INSERT INTO @tbl VALUES(1272,'Bree','Gold')
INSERT INTO @tbl VALUES(1272,'Anneke','silver')
INSERT INTO @tbl VALUES(1272,'Anneke','silver')
SET NOCOUNT ON;
DECLARE @rows INT, @count INT, @message VARCHAR(100);
SET @rows = 1;
SET @count = 0;
BEGIN TRY
BEGIN TRANSACTION;
WHILE @rows > 0
BEGIN
delete top(1) from @tbl where CustomerID=1272
SET @rows = @@ROWCOUNT;
SET @count = @count + @rows
RAISERROR('COUNT %d', 0, 1, @count) WITH NOWAIT
END
COMMIT TRANSACTION;
END TRY
BEGIN CATCH
ROLLBACK TRAN
END CATCH