Creating Views in Azure Synapse Analytics for Serverless SQL Pool | Azure Synapse Tutorial

Creating Views in Azure Synapse Analytics for Serverless SQL Pool

🧱 Creating Views in Azure Synapse Analytics for Serverless SQL Pool

Views are virtual tables that provide a logical abstraction over data. In Azure Synapse Analytics Serverless SQL Pool, creating views allows you to encapsulate complex queries, reuse logic, and build semantic layers on top of data stored in your Data Lake.

✅ Why Use Views in Serverless SQL Pool?

  • Encapsulate logic over flat files like CSV, Parquet, or JSON
  • Improve maintainability and reusability of T-SQL
  • Power BI and other tools can query views directly
  • Views can abstract complex joins and transformations

📘 Syntax to Create a View


CREATE VIEW dbo.MyView AS
SELECT *
FROM OPENROWSET(
    BULK 'https://.dfs.core.windows.net//folder/*.csv',
    FORMAT = 'CSV',
    PARSER_VERSION = '2.0',
    HEADER_ROW = TRUE
) AS [result];

🧪 Example 1: Create View on CSV Files


CREATE VIEW dbo.CustomerView AS
SELECT *
FROM OPENROWSET(
    BULK 'https://techbrotherssynapsestg.dfs.core.windows.net/synpasecontainer/customers/*.csv',
    FORMAT = 'CSV',
    PARSER_VERSION = '2.0',
    HEADER_ROW = TRUE
) AS [result];

🧪 Example 2: Create View with Projection


CREATE VIEW dbo.SalesSummary AS
SELECT 
    CustomerID,
    SUM(SalesAmount) AS TotalSales
FROM OPENROWSET(
    BULK 'https://techbrotherssynapsestg.dfs.core.windows.net/synpasecontainer/sales/*.parquet',
    FORMAT = 'PARQUET'
) AS sales
GROUP BY CustomerID;

🧠 Tips

  • Views are metadata only — data is read on-demand
  • You can query views like any regular table
  • Use sys.views to list all views

📺 Watch the Full Tutorial

Credit: This blog was assisted by ChatGPT and Gemini for generating structured explanations and examples.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.