sqlserver2005删除指定数据库里的所有用户表
简介:这是sqlserver2005删除指定数据库里的所有用户表的详细页面,介绍了和数据库,sqlserver2005,删除指定数据库里的所有用户表有关的知识、技巧、经验,和一些数据库源码等。
--删除指定数据库里的所有用户表,这里删除master里面的所有用户表
use master
--databasename 是待清理的数据库
go
declare @au_lname varchar(40),@sqlstring nvarchar(500)
declare tb cursor for
select name from sysobjects where xtype='u'
open tb
-- perform the first fetch.
fetch next from tb into @au_lname
-- check @@fetch_status to see if there are any more rows to fetch.
while @@fetch_status = 0
begin
-- this is executed as long as the prevIoUs fetch succeeds.
fetch next from tb into @au_lname
set @sqlstring='drop table '+ @au_lname
exec sp_executesql @sqlstring
--drop table @au_lname
end
close tb
deallocate tb
go
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。