I have a stored procedure for select data between many different sql server, and all the sql server have set the link server at the sql server where the stored procedure built in.
Here is my procedure:
Create Proc dbo.spGetData
@code as char(4)
AS
if (@code='aaaa')
Select date From [ServerA].Stock.dbo.Syspara
else if (@code='bbbb')
Select date From [ServerB].Stock.dbo.Syspara
else if (@code='cccc')
Select date From [ServerC].Stock.dbo.Syspara
else if (@code='dddd')
Select date From [ServerD].Stock.dbo.Syspara
GO
If the [ServerB] isn't alive or is closed, when I call:
exec dbo.spGetData 'dddd'
There will be an error, but if the all 4 server are alive, the query will return without error.
How can I do to avoid the problem?