Skip to content

Instantly share code, notes, and snippets.

@kenee
Created March 24, 2013 12:25
Show Gist options
  • Save kenee/5231710 to your computer and use it in GitHub Desktop.
Save kenee/5231710 to your computer and use it in GitHub Desktop.
根据条批量删除表
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