3

I am new to Azure SQL Database. I have a EXTERNAL DATA SOURCE as listed in following link.

CREATE EXTERNAL DATA SOURCE

CREATE EXTERNAL DATA SOURCE [My_data_src] WITH (TYPE = RDBMS, LOCATION = N'myserver', CREDENTIAL = [my_cred], DATABASE_NAME = N'MyDB')

GO

Before creating a new EXTERNAL DATA SOURCE, I need to find out whether this already exists. is there any query or dmv existing to find this?

LCJ
  • 22,196
  • 67
  • 260
  • 418

1 Answers1

5

The following command give you list of all existing External Data Source in database

select  *  from sys.external_data_sources;

To check particular External Data Source, exist or not use following command:

IF  EXISTS (
SELECT  name
FROM sys.external_data_sources
WHERE [name] =  'Name of Datasource'
)
BEGIN
PRINT  'Yes'
END

It will print Yes if Data Source Exist.

Refer - sys.external_data_sources (Transact-SQL)

Pratik Lad
  • 4,343
  • 2
  • 3
  • 11