I understand that in MS SQL Server, if the physical server is down, then the database instance of that service will be not reachable and query shall not be able to execute from this server.
If I have a database stored procedure to fetch data from Linked Servers using IF ELSE
condition, and IF
one of the Linked Server is down, will the query fetch data as 0 and go to ELSE
condition to fetch data from Linked Server 2?
@CSQL = 'SELECT @ROWCOUNT = COUNT(*) from [LinkedServer1].DATABASE.DBO.TABLE'
IF @ROWCOUNT>0
BEGIN
SET @SQL = 'INSERT INTO TABLE SELECT * FROM [LINKEDSEVER1].DATABASE.DBO.TABLE';
EXEC(@SQL);
END
ELSE
BEGIN
SET @SQL = 'INSERT INTO TABLE SELECT * FROM [LINKEDSEVER2].DATABASE.DBO.TABLE';
EXEC(@SQL);
END
Here If [LinkedServer1]
is down, will the query fetch data from [LinkedServer1]
using else condition or due to the first query check @CSQL = 'SELECT @ROWCOUNT = COUNT(*) from [LinkedServer1].DATABASE.DBO.TABLE'
the query will not return any record as the LinkedServer1 is not reachable?
Aucun commentaire:
Enregistrer un commentaire