SQL Server 批量删除用户表的方法

DECLARE @Table NVARCHAR(30) DECLARE tmpCur CURSOR FOR SELECT name FROM sys.objects WHERE TYPE=’U’ AND name LIKE N’%’ OPEN tmpCur FETCH NEXT FROM tmpCur INTO @Table WHILE @@FETCH_STATUS = 0 BEGIN DECLARE @sql VARCHAR(100) SELECT @sql = ‘drop table ‘ + @Table EXEC(@sql) FETCH NEXT FROM tmpCur INTO @Table END CLOSE tmpCur DEALLOCATE tmpCur ]]>

发表评论

电子邮件地址不会被公开。 必填项已用*标注