79416990

Date: 2025-02-06 06:53:10
Score: 2.5
Natty:
Report link

Below statement will first generate drop statement then exec statement will drop those tables from said schema.

DECLARE @droptable NVARCHAR(MAX) SELECT @droptable = COALESCE(@droptable, N'') + 'DROP TABLE [DBA].' + QUOTENAME(TABLE_NAME) + N';' + CHAR(13) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'DBA' and TABLE_TYPE = 'BASE TABLE'

EXEC sp_executesql @droptable

Reasons:
  • No code block (0.5):
  • User mentioned (1): @droptable
  • User mentioned (0): @droptable
  • User mentioned (0): @droptable
  • Low reputation (1):
Posted by: Guddu kumar Mehta