SQL SERVER – List All the Tables for All Databases Using System Tables

Today we will go over very simple script which will list all the tables for all the database.

sp_msforeachdb 'select "?" AS db, * from [?].sys.tables'

Update: Based on comments received below I have updated this article. Thank you to all the readers. This is good example where something small like this have good participation from readers.

Reference : Pinal Dave (http://www.SQLAuthority.com)

SQL Scripts, SQL Stored Procedure, SQL System Table, undocumented SQL
Previous Post
SQLAuthority News – Interview of Author on 60 Seconds with Pinal Dave
Next Post
SQLAuthority News – Starting the SQL Journey – How Did I Get Started With SQL?

Related Posts

Leave a Reply