Click here to Skip to main content
15,913,758 members
Home / Discussions / Database
   

Database

 
GeneralRe: Data on one server, structure on another Pin
Corporal Agarn22-Jul-11 4:27
professionalCorporal Agarn22-Jul-11 4:27 
GeneralRe: Data on one server, structure on another Pin
_Zorro_22-Jul-11 4:50
professional_Zorro_22-Jul-11 4:50 
GeneralRe: Data on one server, structure on another Pin
Corporal Agarn22-Jul-11 5:03
professionalCorporal Agarn22-Jul-11 5:03 
GeneralRe: Data on one server, structure on another Pin
_Zorro_22-Jul-11 5:17
professional_Zorro_22-Jul-11 5:17 
AnswerRe: Data on one server, structure on another Pin
smcnulty200022-Jul-11 20:58
smcnulty200022-Jul-11 20:58 
GeneralRe: Data on one server, structure on another Pin
_Zorro_25-Jul-11 2:37
professional_Zorro_25-Jul-11 2:37 
GeneralRe: Data on one server, structure on another Pin
smcnulty200025-Jul-11 7:33
smcnulty200025-Jul-11 7:33 
GeneralRe: Data on one server, structure on another Pin
_Zorro_25-Jul-11 22:22
professional_Zorro_25-Jul-11 22:22 
Here's why:

CREATE SYNONYM [ schema_name_1. ] synonym_name FOR <object><br />
<br />
<object> :: =<br />
{<br />
    [ server_name.[ database_name ] . [ schema_name_2 ].| database_name . [ schema_name_2 ].| schema_name_2. ] object_name<br />
}<br />


USE tempdb;<br />
GO<br />
-- Create a synonym for the Product table in AdventureWorks2008R2.<br />
CREATE SYNONYM MyProduct<br />
FOR AdventureWorks2008R2.Production.Product;<br />
GO<br />
<br />
-- Query the Product table by using the synonym.<br />
USE tempdb;<br />
GO<br />
SELECT ProductID, Name <br />
FROM MyProduct<br />
WHERE ProductID < 5;<br />
GO<br />


Maybe I'm not seeing it, but how would you manage to use the same procedure and call different databases depending on who called the procedure?

Let's say we have db1 and db2 and we're doing:

SELECT A, B, C FROM dbo.Table

What I need is to call the data from db1 if the application made the call, but go read the data on db2 if the call was made by the build server (the unit/integration tests).
GeneralRe: Data on one server, structure on another Pin
smcnulty200025-Jul-11 8:16
smcnulty200025-Jul-11 8:16 
GeneralRe: Data on one server, structure on another Pin
_Zorro_25-Jul-11 22:24
professional_Zorro_25-Jul-11 22:24 
AnswerRe: Data on one server, structure on another Pin
Mycroft Holmes22-Jul-11 21:24
professionalMycroft Holmes22-Jul-11 21:24 
GeneralRe: Data on one server, structure on another Pin
smcnulty200022-Jul-11 21:32
smcnulty200022-Jul-11 21:32 
GeneralRe: Data on one server, structure on another Pin
Mycroft Holmes23-Jul-11 0:03
professionalMycroft Holmes23-Jul-11 0:03 
GeneralRe: Data on one server, structure on another Pin
David Skelly24-Jul-11 22:36
David Skelly24-Jul-11 22:36 
GeneralRe: Data on one server, structure on another Pin
_Zorro_25-Jul-11 2:45
professional_Zorro_25-Jul-11 2:45 
GeneralRe: Data on one server, structure on another Pin
Mycroft Holmes25-Jul-11 12:13
professionalMycroft Holmes25-Jul-11 12:13 
GeneralRe: Data on one server, structure on another Pin
_Zorro_25-Jul-11 22:15
professional_Zorro_25-Jul-11 22:15 
GeneralRe: Data on one server, structure on another Pin
Mycroft Holmes25-Jul-11 22:43
professionalMycroft Holmes25-Jul-11 22:43 
GeneralRe: Data on one server, structure on another Pin
_Zorro_26-Jul-11 1:53
professional_Zorro_26-Jul-11 1:53 
Questionset password on database in sql server 2005 Pin
SajjadZare21-Jul-11 22:11
SajjadZare21-Jul-11 22:11 
AnswerRe: set password on database in sql server 2005 Pin
Blue_Boy21-Jul-11 22:24
Blue_Boy21-Jul-11 22:24 
JokeRe: set password on database in sql server 2005 Pin
dan!sh 21-Jul-11 22:27
professional dan!sh 21-Jul-11 22:27 
JokeRe: set password on database in sql server 2005 Pin
Blue_Boy21-Jul-11 22:28
Blue_Boy21-Jul-11 22:28 
GeneralRe: set password on database in sql server 2005 Pin
SajjadZare22-Jul-11 0:24
SajjadZare22-Jul-11 0:24 
GeneralRe: set password on database in sql server 2005 Pin
Blue_Boy22-Jul-11 2:56
Blue_Boy22-Jul-11 2:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.