Is there an “IF EXISTS” test for a linked server?

前端 未结 2 676
难免孤独
难免孤独 2020-12-04 01:33

I want to be able to programmatically (in T-SQL) check if a specific linked server already exists for my current server and database (so that if the link doesn\'t exist yet,

相关标签:
2条回答
  • 2020-12-04 01:47
    IF NOT EXISTS ( SELECT TOP (1) * FROM sysservers WHERE srvname = 'myserver\devdb_1' )
    
    0 讨论(0)
  • 2020-12-04 02:05

    Check in sys.servers:

    if not exists(select * from sys.servers where name = N'myserver\devdb_1')
    
    0 讨论(0)
提交回复
热议问题