locked
Query between Azure SQL data warehouse and Azure SQL database RRS feed

  • Question

  • Hello Team,

    I need to query a table present in Azure SQL database from Azure SQL data warehouse.
    So what should be the external data source details in the Azure data warehouse?

    Also,Is there any way by which I can write back in the Azure SQL database table via Azure data warehouse?

    Monday, April 6, 2020 7:06 AM

Answers

  • Hello Nandan Hegde and thank you for your question.

    The External Data Source in Azure Data Warehouse appears to be only for data loading using Polybase, not other SQL databases.

    However you can use elastic query in your Azure SQL database to query the Azure data warehouse.  This way the writing is done by your database, and you do not have to worry about giving write permissions.

    In the Database, create the credentials, then create the external data source:

    CREATE EXTERNAL DATA SOURCE <data_source_name>
    WITH
      ( LOCATION = '<remote_server_name>.database.windows.net'
        , CREDENTIAL = <credential_name>
        , TYPE = RDBMS
        , DATABASE_NAME = '<database_name>' )
    ;
    
    --https://docs.microsoft.com/en-us/sql/t-sql/statements/create-external-data-source-transact-sql?view=azuresqldb-current#overview-azure-sql-database

    Then just

    CREATE EXTERNAL TABLE <Table_name>
    ( 
      <Table_Schema>
    )
    WITH <data_source_name>

    Please let me know if this helps.

    Regards,

    Martin

    • Marked as answer by Nandan Hegde Tuesday, April 7, 2020 5:59 AM
    Tuesday, April 7, 2020 1:20 AM

All replies

  • Hello Nandan Hegde and thank you for your question.

    The External Data Source in Azure Data Warehouse appears to be only for data loading using Polybase, not other SQL databases.

    However you can use elastic query in your Azure SQL database to query the Azure data warehouse.  This way the writing is done by your database, and you do not have to worry about giving write permissions.

    In the Database, create the credentials, then create the external data source:

    CREATE EXTERNAL DATA SOURCE <data_source_name>
    WITH
      ( LOCATION = '<remote_server_name>.database.windows.net'
        , CREDENTIAL = <credential_name>
        , TYPE = RDBMS
        , DATABASE_NAME = '<database_name>' )
    ;
    
    --https://docs.microsoft.com/en-us/sql/t-sql/statements/create-external-data-source-transact-sql?view=azuresqldb-current#overview-azure-sql-database

    Then just

    CREATE EXTERNAL TABLE <Table_name>
    ( 
      <Table_Schema>
    )
    WITH <data_source_name>

    Please let me know if this helps.

    Regards,

    Martin

    • Marked as answer by Nandan Hegde Tuesday, April 7, 2020 5:59 AM
    Tuesday, April 7, 2020 1:20 AM
  • So we cannot query Azure SQL database from Azure SQL data warehouse
    Tuesday, April 7, 2020 5:59 AM
  • That is my understanding, yes.
    Tuesday, April 7, 2020 8:09 PM