Sql Server 2016 errror Incorrect syntax near 'EXTERNAL' I have two SQL Server 2016 VMs in Azure. I am trying to connect these two sql server instances using External datasource. I can safely connect the two instances from my local pc, remotely.
While querying using external table/data source, I am getting this:


Kindly note

i) I have used both RDBMS/SHARD_MAP_Manager

ii) Credential is valid credential

iii) I know, i can use Linked Servers, but i don't want it. As i am planning to move these databases to Sql Azure Db. External Table and datasource is not mandatory. You can suggest alternatives other than LinkedServers.

So i need a query or part of query that will work with both, Sql Server(Virtual/Physical server) and Sql Azure(Db as a Service)

Update

Same query ran flawlessly on Sql Azure db.
External data source type SHARD_MAP_MANAGER and RDBMS is only supported only on Azure SQL Database v12 or later. It is not supported on SQL Server 2016.

Ref:

https://docs.microsoft.com/en-us/sql/t-sql/statements/create-external-data-source-transact-sql

-- Elastic Database query only: a shard map manager as data source   
-- (only on Azure SQL Database v12 or later)  
CREATE EXTERNAL DATA SOURCE data_source_name  
    WITH (   
        TYPE = SHARD_MAP_MANAGER,  
        LOCATION = '&lt;server_name&gt;.database.windows.net',  
        DATABASE_NAME = '\&lt;ElasticDatabase_ShardMapManagerDb'&gt;,  
        CREDENTIAL = &lt;ElasticDBQueryCred&gt;,  
        SHARD_MAP_NAME = '&lt;ShardMapName&gt;'  
    )  
[;]  

-- Elastic Database query only: a remote database on Azure SQL Database as data source   
-- (only on Azure SQL Database v12 or later)  
CREATE EXTERNAL DATA SOURCE data_source_name  
    WITH (   
        TYPE = RDBMS,  
        LOCATION = '&lt;server_name&gt;.database.windows.net',  
        DATABASE_NAME = '&lt;Remote_Database_Name&gt;',  
        CREDENTIAL = &lt;SQL_Credential&gt;  
    )  
[;]