我知道有办法检查链接服务器是否正在运行 我想知道是否有办法在函数内检查它 我写了这段代码:
create function dbo.Ck_DB_Stat
(@servername nvarchar (20))
returns bit
AS
BEGIN
declare @srvr nvarchar(128), @retval int, @res nvarchar (10)
declare @ck bit
set @srvr = @servername;
begin try
exec @retval = sys.sp_testlinkedserver @srvr;
set @ck = 1
end try
begin catch
set @retval = sign(@@error);
end catch;
if @retval <> 0
set @ck = 0
return @ck
END