找回密码
 注册
搜索
热搜: 回贴
微赢网络技术论坛 门户 数据库 查看内容

【T-SQL】清空所有表记录的存储过程

2009-12-14 18:46| 发布者: admin| 查看: 30| 评论: 0|原作者: 慕容紫英

〖天天用,就贴出来吧 use你要清空的库 ......


天天用,就贴出来吧
use 你要清空的库
go
declare @tbname varchar(250)
declare #tb cursor for select name from sysobjects where objectproperty(id,'IsUserTable')=1
open #tb
fetch next from #tb into @tbname
while @@fetch_status=0
begin
exec('delete from ['+@tbname+']')
fetch next from #tb into @tbname
end
close #tb
deallocate #tb

最新评论

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-30 05:31 , Processed in 0.131609 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

返回顶部