NilsBevaart
Programmer
We are scaling out our large database over multiple servers. For this we are setting up distributed querys to access the data. The performance and scalability is great.
Hovever, we want to keep our availability very high. If one of the servers would be offline, the query would return an error. To bypass this, I want to check if a server is online before executing the query. If not, the query is send to a different server with the same dataset (with help of replication)
When I do this with for example a small select statement and capturing the @@error code, the complete stored procedure is stoped due to the high serverity (16) when the server is not available.
I used the following code:
Is there a way to make this work?
Thanks
Nils Bevaart
Hovever, we want to keep our availability very high. If one of the servers would be offline, the query would return an error. To bypass this, I want to check if a server is online before executing the query. If not, the query is send to a different server with the same dataset (with help of replication)
When I do this with for example a small select statement and capturing the @@error code, the complete stored procedure is stoped due to the high serverity (16) when the server is not available.
I used the following code:
Code:
ALTER PROCEDURE prc_LB
AS
DECLARE @Test bit
-- TEST IF SERVER 1 IS ONLINE
SELECT @Test=Operational
FROM [UNI-SRV-BI1].DB1.dbo.tblOperational
-- ON ERROR, SET AVAILABLE=1
IF @@ERROR<>0
BEGIN
SELECT abc FROM MyTable
UNION ALL
SELECT abc FROM [UNI-SRV-BI1].DB1.dbo.MyTable
END
ELSE --USE SERVER 2
BEGIN
SELECT abc FROM MyTable
UNION ALL
SELECT abc FROM [UNI-SRV-BI2].DB1.dbo.MyTable
END
Is there a way to make this work?
Thanks
Nils Bevaart