I have an application with multiple databases using the same schema on the same instance of SQL Server that are storing different information for different groups of users. The users can have access to more than one database. There is a central database that keeps track of which databases the users have access to and a front-end built in ASP.NET. Right now I am using the application to allow the users to select which database they are currently using and then re-writing the connection strings to point them to the right place. What I would like to do is keep track of which DB they are using with an “active_user_database” table in the central DB and pass that on through a view. The syntax would be something like
select * from <database name>.occupants
where <database name> is a dynamic value that I would pull out of the “active_user_database” table.
The goal is to set it up so that the connection from the ASP.NET application only hooks into the central database and allows the user to query the tables in the other databases without having to re-write the connection string. Can anyone suggest a way through this?
Thanks,
Alex
select * from <database name>.occupants
where <database name> is a dynamic value that I would pull out of the “active_user_database” table.
The goal is to set it up so that the connection from the ASP.NET application only hooks into the central database and allows the user to query the tables in the other databases without having to re-write the connection string. Can anyone suggest a way through this?
Thanks,
Alex