Dynamically Specify Linked Server and DB Names in Stored Procedure
- by hgulyan
I have the same query in a stored procedure that needs to be executed on different servers and databases according to parameters.
How can I arrange this without exec or sp_executesql?
I'm using SQL Server 2008.
Thank you.
UPDATE
I've found some links
http://www.eggheadcafe.com/software/aspnet/29397800/dynamically-specify-serve.aspx
http://www.sommarskog.se/dynamic_sql.html
Is using SYNONYM possible solution? If yes, than how?
UPDATE 2
I forgot to mention that all this servers are linked to the server where stored procedure is stored.