1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| DECLARE @Table_Name VARCHAR(50)
DECLARE @Query VARCHAR(250)
DECLARE Table_Cursor CURSOR FOR SELECT Name FROM sys.tables where name like 'integration%_bulk';
DECLARE @Affected_Rows INTEGER = 0
DECLARE @message nvarchar(max)
OPEN Table_Cursor
FETCH NEXT FROM Table_Cursor INTO @Table_Name
WHILE @@FETCH_STATUS = 0
BEGIN
SET @Query = 'truncate table '+@Table_Name+ char(8)
set @message = 'truncate table '+@Table_Name+ char(8)
raiserror(@message,10,1) with nowait;
exec (@Query)
SET @Affected_Rows = @Affected_Rows + COALESCE(@@ROWCOUNT, 0)
FETCH NEXT FROM Table_Cursor INTO @Table_Name
END
SELECT @Affected_Rows AS Affected_Rows
CLOSE Table_Cursor
DEALLOCATE Table_Cursor |
Partager