Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Vienna from September 15-18, 2025, for the ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM. Get registered

Reply
yongshao
Helper III
Helper III

Create SQL views with Fabric lakehouse SQL endpoint from Fabric notebook

Our ETL uses Fabric notebooks to extract/clean/transform big dataset into Fabric lakehouses

We want to create/update SQL Views with a lakehouse SQL endpoint. The  SQL views could be created manually via lakehouse SQL endpoint query console/panel. But we want to automate View creation/update by Fabric notebook

Spark.sql() could create temprary sql views but not persistent views with SQL endpoint

We try to use ODBC/PYDOBC to connect the SQL endpoint and issue the view creattion query, which seems not working either

 

Please help - how to create SQL views with Fabric lakehouse SQL endpoint from Fabric notebook?

5 REPLIES 5
chetnachaudhari
Advocate I
Advocate I

@yongshao We automate our sql views creation using 'script activity' under Data pipelines. 

 

Thanks,

Chetna

yongshao
Helper III
Helper III

Thanks for response

 with Solved: Re: Creating views from spark notebook into SQL an... - Microsoft Fabric Community, a pipeline with script to create a view does work

I wonder why pyodbc driver connection could only query the data but cannot create views from SQL endpoint

 

import pyodbc

server = "?"

database = "?"

username = “?”

pwd = "?"

connection_string = f"Driver={{ODBC Driver 18 for SQL Server}};Server={server};Database={database};Authentication=ActiveDirectoryPassword;UID={username};PWD={pwd};ConnectRetryCount=4"

conn = pyodbc.connect(connection_string)

rows  = conn.execute("select top(10) * from dbo.building")

for row in rows:

     print(row) # works fine

 

#following doesn't work

conn.execute("create view dbo.testView as select top(10) * from dbo.building")

Anonymous
Not applicable

Hi @yongshao ,

Thanks for using Fabric Community.

" Spark views won't show up in the SQL endpoint. It is the same behavior with Synapse Spark too. Views created in Synapse won't show up in Synapse serverless. "

The only option left is to create the views directly in the Lakehouse's SQL Analytics Endpoint.

Similar Threads -
Re: Can you read a Fabric lakehouse view from spar... - Microsoft Fabric Community
Solved: Re: Creating views from spark notebook into SQL an... - Microsoft Fabric Community

Hope this is helpful. Please do let me know incase of further queries.

Anonymous
Not applicable

Hi @yongshao ,

We haven’t heard from you on the last response and was just checking back to see if your query was answered.
Otherwise, will respond back with the more details and we will try to help .

Thanks

Anonymous
Not applicable

Hi @yongshao ,

We haven’t heard from you on the last response and was just checking back to see if your query was answered.
Otherwise, will respond back with the more details and we will try to help .

Thanks

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

May FBC25 Carousel

Fabric Monthly Update - May 2025

Check out the May 2025 Fabric update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.