patternsqlMinor
Does T-SQL have a Schema search path?
Viewed 0 times
pathsearchsqlschemadoeshave
Problem
In T-Sql, a user has a single default schema. Is there a concept of schema search path similar to a postgres search_path?
The question behind the question is, if I use schemas as namespaces for objects, will that mean using qualified names in all code?
The question behind the question is, if I use schemas as namespaces for objects, will that mean using qualified names in all code?
Solution
No. SQL Server will first check the user's default schema for unqualified object references, and then the dbo schema. If not found at this stage, then you get an error.
I've been searching high and low now, but I can't find a reference for this in the product documentation. And it is even hard to find anybody written about this over the whole interweb. I did, however, find this from Bob.
Max Vernon wrote a post showing how this works here.
Aaron Bertrand has some interesting advice about always specifying the schema, here
I've been searching high and low now, but I can't find a reference for this in the product documentation. And it is even hard to find anybody written about this over the whole interweb. I did, however, find this from Bob.
Max Vernon wrote a post showing how this works here.
Aaron Bertrand has some interesting advice about always specifying the schema, here
Context
StackExchange Database Administrators Q#240259, answer score: 7
Revisions (0)
No revisions yet.