Monday, 11 September 2017

MS SQL Server Useful Scripts : Bulk Table Deletion




Need a way to delete all tables at one time ? 






No command or existing function yet out there.

But you can run below to delete all tables at one time.

DECLARE @sql NVARCHAR(max)=''
SELECT @sql += ' Drop table ' + QUOTENAME(TABLE_SCHEMA) + '.'+ QUOTENAME(TABLE_NAME) + '; '
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME like 'et_ticket%'
Exec Sp_executesql @sql

No comments:

Post a Comment

Flag Counter