删除数据库所有用户表(SqlServer)

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

posted @ 2010-05-20 12:34  风飘零  阅读(315)  评论(0编辑  收藏  举报