SELECT TABLE_CATALOG FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'TestTable' : Information_schema « System Settings « SQL Server / T-SQL Tutorial






5> CREATE DATABASE Test
6> GO
1> CREATE TABLE TestTable(
2>    col1   int,
3>    col2   int
4> )
5> GO
1> SELECT TABLE_CATALOG FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'TestTable'
2> GO
TABLE_CATALOG
--------------------------------------------------------------------------------------------------------------------------------
master

(1 rows affected)
1>
2> drop table TestTable;
3> GO
1>
2> drop database Test;
3> GO








26.14.Information_schema
26.14.1.select top 10 * from Information_schema.columns
26.14.2.Information_schema.views
26.14.3.Information_schema.tables
26.14.4.System views INFORMATION_SCHEMA
26.14.5.obtain metadata about database objects.
26.14.6.SELECT TABLE_CATALOG FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'TestTable'
26.14.7.Match a table name in tempdb.INFORMATION_SCHEMA.TABLES
26.14.8.Query tempdb.INFORMATION_SCHEMA.TABLES
26.14.9.A script that creates a summary of the tables in a database
26.14.10.Check the view existance