user2067567
user2067567

Reputation: 3803

Count of DROP Statements Executed for sp_MSforeachtable

enter image description hereAm dropping all the table names in DB using

EXEC sp_MSforeachtable 'DROP TABLE ?'

Is there a way i can get count on number of tables dropped.

Thanks, Peru

Upvotes: 0

Views: 158

Answers (1)

gbn
gbn

Reputation: 432200

DECLARE @before int;

SELECT @before = COUNT(*) FROM sys.tables;
EXEC sp_MSforeachtable 'DROP TABLE ?'
SELECT @before - COUNT(*) FROM sys.tables

Upvotes: 1

Related Questions