Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8185703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:56:29+00:00 2026-06-07T01:56:29+00:00

I am designing a multi-tenant database. Many actions that are needed on a per-tenant

  • 0

I am designing a multi-tenant database. Many actions that are needed on a per-tenant basis have been written as stored procedures. Almost all of them use dynamic SQL execution since I have not found a way to differentiate between the schemas other than with dynamic statements.

EXEC( 'SELECT * FROM ' + @SchemaName + '.Contacts' )

Is there any way to create a variable representing the schema so I can call the select statements without building them dynamically?

SELECT * FROM @TheSchema.Contacts

SQL Server 2008

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T01:56:31+00:00Added an answer on June 7, 2026 at 1:56 am

    FWIW I have found it much more useful to separate customers by database than by schema. Reasons?

    1. All schemas can have identical procedures, thus derive them from model instead of having to create anything. Deployment to multiple databases is no more complex than deployment to multiple schemas, actually less so I’d argue, and the only difference is the application would have to know which database to reference instead of which schema.

    2. Different customers can have different recovery models, be backed up on different schedules, etc. This can improve your backup/restore plan especially as the data set gets larger.

    3. Having each customer in a separate database makes it very easy to move a tenant to a different server if they get too big for the current one. Extracting the data and objects for their schema only will be quite convoluted.

    4. Some customers may legally and/or contractually require that you not store their data in the same database as other customers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may seem totally unreasonable to ask, but I have been designing a multi-panel,
I am designing a multi-file upload service that also shows upload progress for each
I'm in a process of designing a multi-tier ASP.NET web application that is supposed
I'm currently working on a multi-tenant application that employs Shared DB/Shared Schema approach. IOW,
We have been told that Google Chrome runs each tab in a separate process.
We are designing our new product, which will include multi-tenancy. It will be written
I'm designing a database for pure multi-tenancy (one database, one schema) and I'd like
I am designing a multi-tennant web-based SaaS application that will be hosted on Windows
I'm designing an ASP.NET application that must support 'SubSites'. The idea is to have
When designing a database to use MVCC (Multi-Version Concurrency Control), you create tables with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.