sqlserver数据库删除指定数据库特定前缀开头的所有表的sql语句sqlserver删除数据库指定字符开头的所有表的sql语句
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;