SQL Server Best Practices – Using Schemas

schemasql serversql-server-2008

I understand the capabilities of SQL Server Schemas, but what are the best practices? Sure they give another layer of security, and provide logical grouping of database objects within the database, but what is typical out there? I often, in my experience, don't see many custom made schemas utilized. Is this typical? Is it the less-frequent scenario where custom schemas should be used?

Best Answer

We use them

  • to separate permissions per client (eg we have desktop, WebGUI etc schemas)
  • for logical grouping eg (Data and Staging schemas for our tables).

Useful and practical observations past the white paper mentioned by Marian:

  • GRANT on the schema: no more permissions per object. So a new proc in the WebGUI schema automatically has the permissions of the schema
  • Nice groupings in SSMS Object Explorer
  • OBJECT_SCHEMA_NAME
  • You are forced to qualify object names (which is best practice)