I have table and view with same name: "dbo.Users" (table) and "www.Users" (table). There are select statements all over the code that look like this:
SELECT u_id, u_name from Users WHERE ...
I checked with two different users and it seems that view is used in both cases. What are exact rules governing this case? I tried looking for name binding, name search order and similar, but was unable to find anything conclusive in documentation.
The default schema that is used is governed by the "default schema" property for a database user.
You can read this from the
CREATE USERdocumentation:There is a bit more to it when no default schema has been specified for a user:
To avoid situations like that what you have happening, always be explicit by specifying the schema for the database objects you are referencing in queries.