Promotic
WikipediaLinkedInYoutubeTwitterFacebook

sp_tables - statement of language DB_MSSQL

Description:
Returns a list of objects that can appear in the clause FROM (tables, views).
Syntax:

sp_tables

  [[ @table_name =] 'name']

  [, [@table_owner =] 'owner'

  [, [@table_qualifier =] 'qualifier']

  [, [@table_type =] "'type'"]

 
@table_name Name of the returned object with the default value NULL. So called wild-chars '%' and '_' can be used in the name.
@table_owner Owner of the returned object with the default value NULL. So called wild-chars '%' and '_' can be used in the name.
@table_qualifier Database of the returned object with the default value NULL.
@table_type Type of returned objects ('TABLE', 'SYSTEM TABLE', 'VIEW') with the default value NULL. It goes about a list of types, separated by a comma where each type is enclosed in single quotation marks and the whole list in double quotation marks.
Example1:
Display all non-system tables ('TABLE') in the current database.
EXEC sp_tables @table_type="'TABLE'"
Example2:
Display all non-system tables, beginning with specified characters 'da', in the current database (the same by several ways)
EXEC sp_tables @table_name='da%',@table_type="'TABLE'"
EXEC sp_tables 'da%',@table_type="'TABLE'"
EXEC sp_tables 'da%', null, null, "'TABLE'"
EXEC sp_tables 'da%', 'dbo', 'pm_data', "'TABLE'"
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice