Jan 2, 2014

Sql query to get the name schema of given table in sql server


Sql query to get or find the name schema of given or specified table of database in sql server

SELECT s.name
FROM sys.tables t INNER JOIN sys.schemas s
ON t.schema_id = s.schema_id
AND t.name = 'TableName'

Note: Change the table name in the above sql query.

Here sys.tables and sys.schema are system view. sys.tables keeps only user defined tables.
Sys.schemas keeps the all the schema within a database.

Note: Default schema of any database in sql server is dbo (Database object)

No comments:

Post a Comment