Cannot get Linked Servers to work in Sql Azure

前端 未结 4 1449
太阳男子
太阳男子 2021-02-12 19:07

We are using a trial version of Azure. We are trying to perform cross server queries from our SQL 2012 in-house.

We seem to have our local 2012 linked with Azure. When I

4条回答
  •  甜味超标
    2021-02-12 19:49

    This works for me:

    CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'mypassword';
    
    CREATE DATABASE SCOPED CREDENTIAL MySecurity 
    WITH IDENTITY = 'mylogin',
    SECRET = 'mypassword';
    
    CREATE EXTERNAL DATA SOURCE MyDbAccess
    WITH (
        TYPE=RDBMS,
        LOCATION='server name',
        DATABASE_NAME='db_name',
        CREDENTIAL= MySecurity);
    
    CREATE EXTERNAL TABLE MyExtTable (
        [Id] [int]  NOT NULL,
        [Name] [varchar(20)] NULL)
    WITH
    (DATA_SOURCE = MyDbAccess);
    

    After that you can just use it:

    SELECT * FROM MyExtTable

提交回复
热议问题