use [数据库]
GO
DECLARE @name varchar(50)
DECLARE @count int
set @count=0
DECLARE contact_cursor CURSOR FOR
select name from sysobjects
where xtype='u' and name like 'View_%'
OPEN contact_cursor
FETCH NEXT FROM contact_cursor
INTO @name--表名
WHILE @@FETCH_STATUS = 0
BEGIN
print '已经清空表'+@name
set @count=@count+1
exec('truncate table '+@name)
FETCH NEXT FROM contact_cursor
INTO @name
END
print '处理完成,共清空数据表'+convert(varchar(50),@count)+'个'
CLOSE contact_cursor
DEALLOCATE contact_cursor
GO
来源:CSDN
作者:u010818827
链接:https://blog.csdn.net/u010818827/article/details/104698347