Created
March 24, 2013 12:25
-
-
Save kenee/5231710 to your computer and use it in GitHub Desktop.
根据条批量删除表
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @Table NVARCHAR(30) | |
DECLARE tmpCur CURSOR FOR | |
SELECT name FROM sys.objects WHERE TYPE='U' AND name LIKE N'HSUPA%' | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment