Find fully qualified path in SQL Server 2008/2005

It has been observed so many times that when programmer creates table or stored procedure in SQL Server and when tries to run it with its name, they face an error that object doesn’t exists. If you are sure that you have created object even though it is not available even after you are having full permission in database than there is a case that, object owns by particular schema and you are not referring it while calling.
There are few schema in Adventureworks database and each owns few tables. If you try to use table name only in SELECT statement, you will face an error given below.
–try running below query
use AdventureWorks
select * from Address
–it will show you below given error
–Msg 208, Level 16, State 1, Line 1
–Invalid object name ‘Address’.
–reason is Address table is owned by Person schema
–so if you try like below, you are done.
select * from Person.Address
–we have specified schema name and table name in above query
–but the good practise is to specify ServerName.DatabaseName.Schemaname.ObjectName
–this is called fully qualified path and to find out fully qualified path of object
–use below give T-SQL statement.
select ‘[‘+@@SERVERNAME+‘]’  + ‘.’ +DB_NAME() + ‘.’‘.’ as ‘Full Qualified Name’ from sys.objects so join sys.schemas ss
on so.schema_id=ss.schema_id where‘Address’

Reference: Ritesh Shah
Note: Microsoft Books online is a default reference of all articles but examples and explanations prepared by Ritesh Shah, founder of

Very useful Catalog View in SQL Server 2005:

Catalog View is used to get very crucial and important information about your database and server. There are lots of useful Catalog Views are available in Microsoft SQL Server 2005. Herewith, I am going to explain some of them.
Sys.Databases: this catalog view is useful to get information about all the available databases in sql server instance. It will provide you useful information like database name, database id, date of creation, compatibility level (database is compatible to which version of SQL Server, 90 is for SQL Server 2005), collation name (which language we can use in database) etc.
You can use following query for Sys.Databases:
Select * from sys.databases
Sys.Database_files: this catalog view will give us information about particular database’s file. It will give you list of all files which have been used for database. You will get information about which type of files are there for particular database like LOG, DATA and FULLTEXT etc. Along with type of file, it will give you file name, its physical address on the server, state description whether it is ONLINE or OFFLINE, size of each file, growth rate of file etc.
You can use following query for Sys.Database_Files:
–return all files for Adventureworks database
USE AdventureWorks
SELECT * FROM sys.database_files
Sys.Objects: This catalog will cater your need about all the objects available in database. You can get object name, its parent id(if there is any), type description like whether object is system table or user table or foreign key etc.
Below query will return all user tables:
USE AdventureWorks
SELECT * FROM Sys.Objects WHERE Type_Desc=‘User_Table’
Sys.Key_Constraint: this catalog view will give you details about primary key in your database. You can get Parent name, constraint name, and schema id and type description by below query.
SELECT Object_Name(Parent_Object_Id) as ParentName,name,Schema_id,type_desc FROM sys.key_constraints
Sys.Foreign_Key_Columns: You will get information about available foreign key in your database along with its table name and referenced table name with following query.
SELECT Object_Name(Constraint_Object_Id) as ‘Name’,Object_Name(Parent_Object_Id) AS ‘TableName’,Object_Name(Referenced_Object_id) AS ‘Referenced Table’ FROM sys.foreign_key_columns
Sys.Columns: You will get information about all columns available in all tables for selected database. You will get Table name, column name, and collation name, null value status for column, maximum length and precision of columns by following query.
SELECT Object_Name(Object_Id) as ‘TableName’,Name as ‘ColumnName’,collation_Name,is_nullable,max_length,precision FROM Sys.Columns
There many more catalog views are available in SQL Server 2005, I will cover few more in my later article.
Reference: Ritesh Shah