• sql_er (1/7/2013)


    Group 2: Needs to be able to do anything within the database (dbo)

    Membership in the db_owner Role (could be many members) is not the same as the dbo user. Know that dbo (a Database User in every database linked to sa Server Login), the db_owner Fixed Database Role and the database owner (the Server Login that actually owns the database) are three different things and it is important to make the proper distinctions when discussing permissions because they imply different things.

    Questions:

    1. Is what I am observing the expected behavior?

    Yes. What you are seeing is the expected behavior for Database Users based on Windows Groups in SQL 2005, SQL 2008 and SQL 2008 R2. In SQL 2012 we have the ability to define a default schema for a Database User based on a Windows Group which is a feature added to respond to the presumably undesirable behavior you are seeing.

    2. How do people deal with the issue - do they enforce all the users to specify dbo or is there a way to set the default schema at the group level?

    Yes. I enforce this through code reviews. It is a best practice to schema-qualify your objects, unless you are in a multi-tenant database using a tenant-by-schema approach in which case it is expected that developers not schema-qualify object references.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato