Query External and Dedicated Tables

Wajih Arfaoui 70 Reputation points
2024-03-18T13:26:24.0933333+00:00

Hello,

I would like to know if it is feasible to use a dedicated table and an external table in the same SQL query, for example to do a join between both ?

Thank you,

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,378 questions
{count} vote

2 answers

Sort by: Most helpful
  1. Vinodh247 34,741 Reputation points MVP Volunteer Moderator
    2024-03-18T13:33:28.62+00:00

    Hi Wajih Arfaoui,

    Thanks for reaching out to Microsoft Q&A.

    Yes, It should. Suppose you have a dedicated table called 'dedtbl' and an external table called 'exttbl'. You can perform joins, filters, and aggregations across these tables.

    SELECT    ds.ProductID,     ds.SalesAmount,     es.ProductName FROM    dedtbl ds JOIN 
    exttbl es ON ds.ProductID = es.ProductID;
    
    

    Ensure that the column definitions (data types, etc.) match between the dedicated and external tables. The actual data resides externally hence performance considerations may differ based on the data source. The benefit is that the external tables do not require compute resources, so you don’t need to unpause the dedicated sql pool to work with them.

    Try and let me know.

    Please 'Upvote'(Thumbs-up) and 'Accept' as an answer if the reply was helpful. This will benefit other community members who face the same issue.


  2. Smaran Thoomu 24,260 Reputation points Microsoft External Staff Moderator
    2024-03-19T05:57:52.6666667+00:00

    Hi @Wajih Arfaoui

    Thank you for reaching out to the community forum with your query.

    In addition to the above answer. It is feasible to use both a dedicated table and an external table in the same SQL query, including doing a join between them.

    To join an external table with a dedicated table, you can use the T-SQL syntax for joining tables. For example, you can use the following syntax to join an external table named "external_table" with a dedicated table named "dedicated_table" on a common column named "common_column":

    SELECT * 
    FROM external_table 
    JOIN dedicated_table ON external_table.common_column = dedicated_table.common_column;
    
    
    

    You can also use the same syntax to join multiple external tables with dedicated tables or with other external tables.

    For more information on joining tables in Azure SQL Database, you can refer to Join tables in Azure SQL Database.

    Hope this helps. Do let us know if you any further queries.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.