ksutphin
Programmer
- Jan 27, 2005
- 11
I have many situations where I have to write stored procedures across multilple servers because our shipping systems is on a different server than our accounting server.
For Example
Select *
From accserver.db1.dbo.Table1 t1 join
shpserver.db2.dbo.Table2 t2 on t1.Order = t2.Order
This always works fine. The problem comes about if we have to restore to a back up server. The other day our main accounting server went down and we had to restore to the accounting databases to a back up server, with a different name. When this happens, we have to alter the stored procedures running on the shipping server to read as follows..
Select *
From accdkupserver.db1.dbo.Table1 t1 join
shpserver.db2.dbo.Table2 t2 on t1.Order = t2.Order
This becomes a hassle because we have a lot of stored procedures to change, and then change back when we get the main server back on line.
Is there a way to use a variable for the path ('accserver.db1.') that can possibly pull from a table?
If that's not possible is there a way to do what would basically be a 'replace' for the server name in all the stored procedures? I'm thinking this may be possible using sysobjects but I'm not sure.
ksutphin
For Example
Select *
From accserver.db1.dbo.Table1 t1 join
shpserver.db2.dbo.Table2 t2 on t1.Order = t2.Order
This always works fine. The problem comes about if we have to restore to a back up server. The other day our main accounting server went down and we had to restore to the accounting databases to a back up server, with a different name. When this happens, we have to alter the stored procedures running on the shipping server to read as follows..
Select *
From accdkupserver.db1.dbo.Table1 t1 join
shpserver.db2.dbo.Table2 t2 on t1.Order = t2.Order
This becomes a hassle because we have a lot of stored procedures to change, and then change back when we get the main server back on line.
Is there a way to use a variable for the path ('accserver.db1.') that can possibly pull from a table?
If that's not possible is there a way to do what would basically be a 'replace' for the server name in all the stored procedures? I'm thinking this may be possible using sysobjects but I'm not sure.
ksutphin