Find tables with names with specific prefix

Query below finds tables which names start with specific prefix, e.g. tables with names starting with 'C' in the 'Sales' database.

Query

SELECT  DatabaseName,
        TableName
FROM    DBC.TablesV
WHERE   TableKind = 'T'
AND     TableName LIKE 'C%'
AND     DatabaseName = 'Sales'
ORDER BY    TableName;

Columns

  • DatabaseName - name of database (redundant as it should be exactly the same as provided)
  • TableName - name of found table

Rows

  • One row represents one table
  • Scope of rows: all found tables in 'Sales' database
  • Ordered by table name

Sample results

Comments are only visible when the visitor has consented to statistics cookies. To see and add comments please accept statistics cookies.
0
There are no comments. Click here to write the first comment.