写了一个针对一个数据库的所有表进行的存储过程!可以方便的清空数据库!
发表于:2007-07-02来源:作者:点击数:
标签:
/* --下面的调下将清空 数据库 exec TruncateDatabase @#truncate %tablename%@# */ alter proc dbo.TruncateDatabase @SqlExecute varchar(3000)=@#Select * from %tablename%@# as begin declare @tablename varchar(100) ,@ sql varchar(3000) --定义游标
/*
--下面的调下将清空
数据库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
原文转自:http://www.ltesting.net