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
Change is inevitable... Change for the better is not.