Hey everyone!
I'd like to set a parameter for the name of a server and have it write like this. We'll used the link server procedure to link to the new server when doing some comparisons
Declare @ServerName varchar(10);
Set @ServerName = 'DDD-111'
Set @ServerName2 = @ServerName --This is temp...until we get the new server up
--this gives me an error asking me to link to the server (although I'm in the server)
Select *
From [@ServerName].[Database].[dbo].[TableName]
Join
[@ServerName2].[Database].[dbo].[TableName]
--However when I run it like this, it works fine
Select *
From [ServerName].[Database].[dbo].[TableName]
Join
[ServerName].[Database].[dbo].[TableName]
What I want to do is write one long script, have these a parameter at the top and then just execute it. So I wouldn't have to go through each query and change the name of the server.
Everyday life brings me back to reality