cross-database

Suggestions on retrieving related data across databases with different logins?

I have an array of user ids in a query from Database A, Table A (AA). I have the main user database in Database B, Table A (BA). For each user id returned in my result array from AA, I want to retrieve the first and last name of that user id from BA. Different user accounts control each database. Unfortunately each login cannot have ...

Cross-database views and mirroring in SQL Server

Hi, I have a question about mirroring and cross-db views. We have a view in database X which references database Y on the same server S1. The databases X & Y are both mirrored onto another server S2. The problem is: if db X fails over to S2, the view which references db Y is now looking on S2, but db Y may not have failed over. What is ...

SQL Server Replication (cross-database queries & constraints)

We want to replicate data from one database to several others (on another server). Would it make sense to replicate these tables to a shared database on the other server and have our cross-database queries reference the shared database... or would it make more sense to replicate out to each individual database on the other server? Would ...

LINQ to SQL: Get records from two DB's that are on different servers.

I need to fetch records from tables, that are in two diff. databases in two different SQL Servers. For Instance. Sales DB on server1 and Purchase DB on server2. Both Sales and Purchase DB's have some set of tables say table1 in Sales DB and table2 in Purchase DB. Now, I need to get records from table1 and table2 that are having some co...

EF4 cross database relationships

Hello all, I was wondering if EF4 support cross-databse relationships? For instance: db1 Author Id Name db2 Posts Id Content db1.Author.Id What ideally I need to do to get this relation in my ef4 model? Do you guys have any idea? Thanks ...

performance effect of joining tables form different databases

I have a web site using a database named lets say "site1". I am planning to put another site on the same server which will also use some of the tables from "site1". So should I use three different databases like "site1" (for first site specific data), "site2" (for second site specific data), and "general" (for common tables). In which ...

Cross-database view permissions

I'm working with a database (let's call it DB_data) that contains all of the tables for a series of applications. In an attempt to minimize downtime during upgrades, a facade database (let's call it DB_facade) has been created which has a view for each of the tables in DB_data. It also contains all of the functions and stored procedures,...

Avoiding the use of SET TRUSTWORTHY ON

I'm working with a system which had to create objects in one database based on objects being created in another database. The objects are not duplicates, so I can't simply replicate the objects. I have code below which gives a simplified demonstration of what I'm trying to do. If you uncomment the ALTER DATABASE statements then it will ...

SQL Server cross database query when the other DB name is not known in advance?

Given a multi-tenant setup with one database that holds the tenant data, and one database for each tenant, how can you construct a query to look up the same piece of data in each tenant database? eg The tenant master database has a table called Tenants: [TenantMaster].[dbo].[Tenants] Id, Name, DatabaseName 1, Bob, bobs_db_name 2, Kate,...

Running trigger that calls stored procedure on another database

We would like to run a trigger on one database (A) that calls a stored procedure on another database (B). CREATE TRIGGER trg_A ON TableA FOR INSERT AS BEGIN EXEC DatabaseB.dbo.stp_B END We would like to do this as LoginA with UserA on DatabaseA. We also have LoginB with UserB on DatabaseB. How can we accomplish this? Currently w...