This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing a script for dropping a table from all databases of SQL Server.
We are creating different versions of the database in our environment. Recently, I found some test/temp tables which are replicated in all versions databases.
In this case, you can use below script and drop those tables from all the databases. As per your requirement, you can add more option in a dynamic query.
Use sp_MSforeachdb, and execute a command in all databases:
1 2 3 |
exec sp_MSforeachdb 'use [?] drop table table_name' |
SQL Server: Who dropped a Table and Which Table has been dropped
SQL Server: Who dropped a table, find out from Transaction Log
Leave a Reply