List All Tables In A Specified Database

 

This SQL server script will display all of the SQL user type tables in a given database using DatabaseName and SqlQuery variables.

 

SQL Query:

 

Declare @DatabaseName SysName

Declare @SqlQuery VarChar(200)

 

-- Change SMS_XXX To The Database you wish to query

Set @DatabaseName='SMS_XXX'

Set @SqlQuery='Select Table_Name as Tables From ' + @DatabaseName + '.Information_Schema.Tables

 

Where Table_Type = ''Base Table'''

Exec (@SqlQuery)

 

 

 

Published Sunday, February 17, 2008 3:08 PM by dhite
Filed under:

Comments

No Comments