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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
mail2atulm
Regular Visitor

How to perform DML(insert/delete/update) on Fabric SQL database using Notebook

Hi All,

 

 I have created new Fabric SQL database. On this Fabric database I want to perform various operation on Fabric SQL database table like Insert/update/delete specifically from Fabric Notebook within same Workspace.

 

I tried DMP opertaion using Data pipeline which is working fine BUT we need these DMP opertation to be performed from existing Notebooks.

 

Kindly help  how do I need to connect to Fabric SQL database from Fabric notebook and perform DML operation.

 

Thanks in advance

 

1 ACCEPTED SOLUTION
v-prasare
Community Support
Community Support

Hi @mail2atulm,

 

To perform INSERT, UPDATE, and Delete operations on your Fabric SQL database directly from a Fabric notebook within the same workspace. If your database is a Fabric Warehouse or a Mirrored SQL database with an analytics endpoint, the easiest way is to use the %%sql magic command in the notebook. You can simply write standard T-SQL commands like INSERT, UPDATE  or Delete inside a %%sql cell, and it will execute directly against your database.

If you're using a Spark-based notebook or need more control, you can also connect to your Fabric SQL database using a JDBC connection within Python. This lets you write data from a DataFrame to your SQL table or execute more complex logic programmatically. You'll need your database connection details like the endpoint, database name, and credentials (or managed identity), and then you can use Spark’s write jdbc() function to perform your DML tasks. For more detailed guidance, you can refer to the official documentation on connecting to your SQL database in Microsoft Fabric: Connect to Your SQL Database - Microsoft Fabric.(Microsoft Learn)

 

 

 

Thanks,

Prashanth Are

MS Fabric community support

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly and give Kudos if helped you resolve your query

View solution in original post

1 REPLY 1
v-prasare
Community Support
Community Support

Hi @mail2atulm,

 

To perform INSERT, UPDATE, and Delete operations on your Fabric SQL database directly from a Fabric notebook within the same workspace. If your database is a Fabric Warehouse or a Mirrored SQL database with an analytics endpoint, the easiest way is to use the %%sql magic command in the notebook. You can simply write standard T-SQL commands like INSERT, UPDATE  or Delete inside a %%sql cell, and it will execute directly against your database.

If you're using a Spark-based notebook or need more control, you can also connect to your Fabric SQL database using a JDBC connection within Python. This lets you write data from a DataFrame to your SQL table or execute more complex logic programmatically. You'll need your database connection details like the endpoint, database name, and credentials (or managed identity), and then you can use Spark’s write jdbc() function to perform your DML tasks. For more detailed guidance, you can refer to the official documentation on connecting to your SQL database in Microsoft Fabric: Connect to Your SQL Database - Microsoft Fabric.(Microsoft Learn)

 

 

 

Thanks,

Prashanth Are

MS Fabric community support

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly and give Kudos if helped you resolve your query

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

June FBC25 Carousel

Fabric Monthly Update - June 2025

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