Print all the database names in a SQL Server Instance
Print all the tables in all the databases of a SQL Server Instance
The example shown above prints the tables for master, model, msdb and tempdb. If you want to eliminate these databases in the query use, do the following:
Display the size of all databases in a SQL Server instance
Determine all the physical names and attributes(size,growth,usage) of all databases in a SQL Server instance
Change Owner of all databases to 'sa'
Check the Logical and Physical integrity of all objects in the database
Similarly you can backup all databases at one go or do a CHECKSUM using this useful procedure. There are many more ways to use it. Got a useful tip on sp_MSforeachdb? Share it using the comments below.
Did you like this post?
|subscribe via rss||subscribe via e-mail|
|print this post||follow me on twitter|