/*
–下面的调下将清空数据库
exec truncatedatabase truncate %tablename%
*/
alter proc dbo.truncatedatabase
@sqlexecute varchar(3000)=select * from %tablename%
as
begin
declare @tablename varchar(100)
,@sql varchar(3000)
–定义游标
declare mycur cursor for
select name from dbo.sysobjects where xtype=u
–打开
open mycur
fetch next from mycur into @tablename
while @@fetch_status=0
begin
set @sql=replace(@sqlexecute,%tablename%,@tablename)
–执行操作
print @sql
execute(@sql)
–到下一个表
fetch next from mycur into @tablename
end
close mycur
deallocate mycur
end
go