程序员人生 网站导航

SQL Server 如何删除数据库所有用户表?

栏目:Sqlserver时间:2014-03-10 16:47:25
sqlserver 查询分析器里面执行即可

DECLARE curItems CURSOR
FOR select [name] from sysobjects where xtype='U'
FOR READ ONLY
OPEN curItems
DECLARE @n NVARCHAR(100),@m NVARCHAR(100)
FETCH FROM curItems INTO @n
WHILE @@FETCH_STATUS=0
BEGIN
set @m=@n
exec('Drop Table ' + @m)
FETCH NEXT FROM curItems INTO
@n
END
CLOSE curItems
DEALLOCATE curItems
------分隔线----------------------------
------分隔线----------------------------

最新技术推荐