• aaron.reese (12/11/2013)


    Oops!

    I should know better than to make throwaway statements like that when Jeff or Gill are lurking 😀

    I will have to find some time to set it up on my development system but I am pretty sure you can have

    FOO.Customers

    and

    BAR.Customers

    with the same table structure.

    FOO and BAR are schemas that are owned by different user groups and they only have access to their own schema so when a Bob logs on and runs

    SELECT * from Customers, this will run against FOO.Customers

    and likewise when a Jim logs on it will run against BAR.Customers

    so unless your stored procedures include the EXECUTE AS command they will run under the correct context for the login

    Not sure what it will do to the cached execution plans though if the statistics for the different schemas are skewed 🙂

    Actually, that's a pretty darned good example of when single part naming works very well. I've not had to work in an environment where such naming was required but I can certainly see it happening in a good number of environments.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)