SQL Server 删除master数据库特定前缀开头的所有表的sql语句
USE master; DECLARE @TableName NVARCHAR(128); DECLARE @SQL NVARCHAR(MAX); DECLARE TableCursor CURSOR FOR SELECT name FROM sys.tables WHERE name LIKE 'Whir%'; OPEN TableCursor; FETCH NEXT FROM TableCursor INTO @TableName; WHILE @@FETCH_STATUS = 0 BEGIN SET @SQL = 'DROP TABLE ' + QUOTENAME(@TableName); EXEC sp_executesql @SQL; FETCH NEXT FROM TableCursor INTO @TableName; END; CLOSE TableCursor; DEALLOCATE TableCursor;