Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm currently creating a Multi-tenant data architecture in a SaaS BI-product.

The product are using shared database and shared schema, but with tenant view filters and tenant data encryption (Inspiration found here:

When creating the view filter, I can do both these:

CREATE VIEW TenantEmployees AS

CREATE VIEW TenantEmployees AS

Using SID() I am using the Security Identifier that looks something like this:


Using ID() I am using the normal Identifier that looks something like this:


Which one is the absolute best to use and why? :) I expect that both are absolutely unique and will never be reused in newer user-logins

share|improve this question
up vote 5 down vote accepted

I'd use SUSER_SID for this reason:

  • SUSER_ID is the principal_id column in sys.server_principals
  • SUSER_SID is the SID column in sys.server_principals and be generated by Active Directory (Windows login) or SQL Server

If you move the database to another server

  • then SUSER_ID will almost certainly be different.
  • SUSER_SID will be the same for Windows logins, but can be made the same for SQL logins by specifiying SID for CREATE LOGIN.
share|improve this answer
Perfect explanation.. thanks! :) Now I just need to figure out how precisely to use the view filters for all tables :) – Behrens Feb 14 '12 at 11:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.