Friday, January 29, 2010

Why the qualified naming is important

When we call an object without specifying the schema (unqualified name), SQL Server searches it in following sequence:
1. In sys schema
2. In users default schema
3. In dbo schema
Inside the procedural objects (like stored procedure, function, view) called object is searched in following sequence:
1. In sys schema
2. In default schema of procedural object’s owner. This behavior can be changed by using the EXECUTE AS clause.
3. In dbo schema
So the qualified name (schema.object) is important in two aspects:
1. In getting the right object.
2. In improving the performance of searching an object.

No comments: