Forum Discussion
Support - SQL Analytics Endpoint Feasibility for Pipeline Orchestration in Fabric
- Anonymous1 year ago
Hi Sureshmannem,
To your follow-up: yes, you can execute SQL queries and stored procedures from within a Notebook in Fabric, using the built-in %%sql magic command.
* Running a SQL Query saved in the Lakehouse (via SQL Analytics Endpoint). If you’ve saved a query (for example, a view or just want to run a raw T-SQL statement), you can execute it like this:
%%sql
SELECT * FROM YourLakehouse.dbo.YourTableOr if you’ve created a view or saved query:
%%sql
SELECT * FROM dbo.YourSavedViewMake sure the the Notebook must be attached to the Lakehouse you're querying, and the SQL Analytics Endpoint must be published.
* For executing a stored procedure
If you’ve defined a stored procedure in the SQL Endpoint (something like usp_MyProcedure), you can call it like this:
%%sql
EXEC dbo.usp_MyProcedureAnd If your stored procedure takes parameters:
%%sql
EXEC dbo.usp_MyProcedure @Param1 = 'Value1', @Param2 = 123If I misunderstand your needs or you still have problems on it, please feel free to let us know.
Best Regards,
Hammad.
Hi Anonymous
Thanks for your support — this will definitely help us reuse our existing code base more effectively.
I have a quick question:
Is it possible to run SQL queries that are saved in a Lakehouse using a SQL endpoint from within a notebook? If so, could you please share a simple example of how to execute:
- A SQL query saved in the endpoint
- A stored procedure
Thanks in advance!
Hi Sureshmannem,
To your follow-up: yes, you can execute SQL queries and stored procedures from within a Notebook in Fabric, using the built-in %%sql magic command.
* Running a SQL Query saved in the Lakehouse (via SQL Analytics Endpoint). If you’ve saved a query (for example, a view or just want to run a raw T-SQL statement), you can execute it like this:
%%sql
SELECT * FROM YourLakehouse.dbo.YourTable
Or if you’ve created a view or saved query:
%%sql
SELECT * FROM dbo.YourSavedView
Make sure the the Notebook must be attached to the Lakehouse you're querying, and the SQL Analytics Endpoint must be published.
* For executing a stored procedure
If you’ve defined a stored procedure in the SQL Endpoint (something like usp_MyProcedure), you can call it like this:
%%sql
EXEC dbo.usp_MyProcedure
And If your stored procedure takes parameters:
%%sql
EXEC dbo.usp_MyProcedure @Param1 = 'Value1', @Param2 = 123
If I misunderstand your needs or you still have problems on it, please feel free to let us know.
Best Regards,
Hammad.