Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Joining Tables in Different DBs

Author  Topic 

coderdude
Starting Member

24 Posts

Posted - 2003-09-16 : 13:36:10
I currently have both the development and production versions of two databases on the same SQL server. So I have 4 databases in all:

DB1Dev
DB2Dev

DB1Prod
DB2Prod

I have written a stored procedure in DB1Dev database that joins a to a table in the DB2Dev database. Here's a sample:

SELECT *
FROM DB1Dev.dbo.Table1 T1
INNER JOIN DB2Dev.dbo.Table2 T2
ON T1.Key = T2.Key

So my problem is... when I move this stored procedure to the production database DB1Prod I have to manually change all the "Dev" to "Prod" to make it join the correct databases!

Is there an easier way to do this?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-09-16 : 13:37:56
That's why you never should name your databases like that. You should be using multiple instances of SQL Server instead of having multiple environment databases on one server.

There is no easier way. You should rename your databases so that they do not include the environment name, such as dev, prod, test, qa, etc...

Tara
Go to Top of Page

coderdude
Starting Member

24 Posts

Posted - 2003-09-16 : 13:55:39
Now why didn't I think of using multiple SQL server instances?

THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU!
Go to Top of Page
   

- Advertisement -