Home » Reply » Reply To: How to delete all tables in SQL Server database?

Reply To: How to delete all tables in SQL Server database?

Andrew Jackson ~ Modified: November 6th, 2015 ~ ~ 1 Minute Reading

Home Forums How to delete all tables in SQL Server database? Reply To: How to delete all tables in SQL Server database?

#884 Score: 0
Andrew Jackson
Moderator
1 pt

Try this query

declare @SQL nvarchar(max)

SELECT @SQL = STUFF((SELECT ', ' + quotename(TABLE_SCHEMA) + '.' + quotename(TABLE_NAME) 

FROM INFORMATION_SCHEMA.TABLES WHERE Table_Name LIKE '%lku'
FOR XML PATH('')),1,2,'')

SET @SQL = 'DROP TABLE ' + @SQL

PRINT @SQL