刪除資料庫所有使用者表(SqlServer)

iSQlServer發表於2010-05-20

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

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/16436858/viewspace-663198/,如需轉載,請註明出處,否則將追究法律責任。

相關文章