declare cu cursor for SELECT [name] FROM SYSTABLEIDVIEW where [name] like '%Staging'
declare @table varchar(100)
declare @sql nvarchar(1000)
OPEN cu
FETCH NEXT FROM cu INTO @table
WHILE @@FETCH_STATUS = 0
BEGIN
set @sql = N'delete from ' + @table
PRINT @table
EXEC sp_executesql @sql
FETCH NEXT FROM cu INTO @table
END
CLOSE cu;
DEALLOCATE cu;
No comments:
Post a Comment