Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Conditionally choose linked server

$
0
0

Hi,

Have a stored procedure that accesses data via a linked server.  Whilst testing we point to a test linked server and then change the procedure to a different one when it goes live.  Not ideal.

Was wondering if there's a way to conditionally select the the linked server, sort of like this but a bit more elegantly.

IF (@Debug =1)
BEGIN 
   SELECT * FROM [DebugServer].[DB].dbo.table;
END 
ELSE BEGIN 
   SELECT * FROM [LiveServer].[DB].dbo.table;
END 



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>