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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Soobramoney
Advocate I
Advocate I

Lakehouse - Creating stored procs using Notebooks

Hi guys,

 

Is it possible to create a stored proc on Fabric lakehouse from a notebook?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @Soobramoney,

Perhaps you can use the pyodbc to connect to the data source and execute the create SP command:

import pyodbc

# copy and paste the SQL endpoint from any of the Lakehouses or Warehouses in your Fabric Workspace          
server = "your endpoint"
# copy and paste the name of the Lakehouse or Warehouse you want to connect to
database="YourDatabase"

# use Service principal to connect
clientId = ""
clientSecret = mssparkutils.credentials.getSecret("https://YourKeyVault.vault.azure.net/","your-client-secret-secret-name")

constr = f"driver=ODBC Driver 18 for SQL Server;server={server};database={database};UID={clientId};PWD={clientSecret};Authentication=ActiveDirectoryServicePrincipal;Encrypt=yes;Timeout=60;"

con = pyodbc.connect(constr)

cursor = con.cursor()

create_SP_Command=""

result=cursor.execute(create_SP_Command)

print(result)

cursor.close()
con.close()

Load data to MS Fabric Warehouse from notebook - Stack Overflow

Regards,

Xiaoxin Sheng

View solution in original post

1 REPLY 1
Anonymous
Not applicable

HI @Soobramoney,

Perhaps you can use the pyodbc to connect to the data source and execute the create SP command:

import pyodbc

# copy and paste the SQL endpoint from any of the Lakehouses or Warehouses in your Fabric Workspace          
server = "your endpoint"
# copy and paste the name of the Lakehouse or Warehouse you want to connect to
database="YourDatabase"

# use Service principal to connect
clientId = ""
clientSecret = mssparkutils.credentials.getSecret("https://YourKeyVault.vault.azure.net/","your-client-secret-secret-name")

constr = f"driver=ODBC Driver 18 for SQL Server;server={server};database={database};UID={clientId};PWD={clientSecret};Authentication=ActiveDirectoryServicePrincipal;Encrypt=yes;Timeout=60;"

con = pyodbc.connect(constr)

cursor = con.cursor()

create_SP_Command=""

result=cursor.execute(create_SP_Command)

print(result)

cursor.close()
con.close()

Load data to MS Fabric Warehouse from notebook - Stack Overflow

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
April Fabric Update Carousel

Fabric Monthly Update - April 2026

Check out the April 2026 Fabric update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.