Stored procedures¶
Manage stored procedures on Microsoft Fabric Data Warehouses and SQL Analytics Endpoints.
Targets: Data Warehouse / SQL Analytics Endpoint
CLI¶
procedures create¶
Targets: Data Warehouse / SQL Analytics Endpoint
Create a new stored procedure.
Synopsis
| Option | Description |
|---|---|
--name SCHEMA.PROC |
Required. Qualified procedure name (e.g. dbo.usp_load_sales). |
--body TEXT |
Inline procedure body (the AS … section). |
--from-file PATH |
Path to a .sql file containing the procedure body. |
Exactly one of --body or --from-file must be provided.
Example
fdw -w MyWorkspace procedures create SalesWH \
--name dbo.usp_archive_orders \
--body "BEGIN INSERT INTO dbo.archive SELECT * FROM dbo.orders; END"
procedures drop¶
Targets: Data Warehouse / SQL Analytics Endpoint
Drop a stored procedure. You will be asked to confirm unless --yes is passed.
Synopsis
Example
procedures get¶
Targets: Data Warehouse / SQL Analytics Endpoint
Get the full definition of a single stored procedure.
Synopsis
QUALIFIED_NAME must be a dot-separated schema.proc_name string, e.g. dbo.usp_load_sales.
Example
procedures list¶
Targets: Data Warehouse / SQL Analytics Endpoint
List stored procedures on a warehouse or SQL Analytics Endpoint. Pass --schema to filter to a single schema.
Synopsis
| Option | Description |
|---|---|
--schema TEXT |
Only list procedures in this schema. |
Example
schema_name name created modified
------------ --------------- --------------------- ---------------------
dbo usp_load_sales 2026-01-10T08:00:00Z 2026-06-01T12:00:00Z
procedures update¶
Targets: Data Warehouse / SQL Analytics Endpoint
Redefine an existing stored procedure via CREATE OR ALTER PROCEDURE.
Synopsis
QUALIFIED_NAME is the dot-separated schema.proc_name to update.
| Option | Description |
|---|---|
--body TEXT |
Inline procedure body. |
--from-file PATH |
Path to a .sql file containing the procedure body. |
Exactly one of --body or --from-file must be provided. You will be asked to confirm unless --yes is passed.
Example
fdw -w MyWorkspace procedures update SalesWH dbo.usp_archive_orders \
--from-file ./procs/usp_archive_orders_v2.sql
procedures transfer¶
Targets: Data Warehouse / SQL Analytics Endpoint
Move a stored procedure to another schema via ALTER SCHEMA ... TRANSFER OBJECT::.... The command emits exactly ALTER SCHEMA [target_schema] TRANSFER OBJECT::[schema].[proc], with every identifier validated and bracket-quoted before being embedded in the DDL.
Definition text is not rewritten
ALTER SCHEMA ... TRANSFER moves the procedure, but it does not rewrite
the schema name inside the object's stored definition
(sys.sql_modules.definition, OBJECT_DEFINITION()). After a transfer,
get_procedure may still show the old schema name in the CREATE ... AS
header, even though the procedure now lives in the new schema. This tool does
not rewrite the definition text: doing so would require parsing and
regenerating SQL, which this project deliberately avoids. See
ALTER SCHEMA (Transact-SQL).
Synopsis
QUALIFIED_NAME is the current dot-separated schema.proc_name.
| Option | Description |
|---|---|
--target-schema TEXT |
Required. Schema to move the procedure into. |
You will be asked to confirm unless --yes is passed.
Example
MCP tools¶
create_procedure¶
Targets: Data Warehouse / SQL Analytics Endpoint
Create a new stored procedure.
Caution
body is executed verbatim as DDL. Ensure the body matches the user's intent before calling this tool.
Parameters:
workspace(str): workspace name or GUID.item(str): warehouse or SQL analytics endpoint name or GUID.qualified_name(str): dot-separated qualified procedure name, e.g.dbo.usp_load.body(str): the procedure body (theAS …section).
Returns: StoredProcedure: the newly-created procedure object.
drop_procedure¶
Targets: Data Warehouse / SQL Analytics Endpoint
Drop a stored procedure.
Parameters:
workspace(str): workspace name or GUID.item(str): warehouse or SQL analytics endpoint name or GUID.qualified_name(str): dot-separated qualified procedure name, e.g.dbo.usp_load.
Returns: { "dropped": true }: confirmation.
get_procedure¶
Targets: Data Warehouse / SQL Analytics Endpoint
Fetch the full definition of a single stored procedure.
Parameters:
workspace(str): workspace name or GUID.item(str): warehouse or SQL analytics endpoint name or GUID.qualified_name(str): dot-separated qualified procedure name, e.g.dbo.usp_load.
Returns: StoredProcedure: single procedure object with definition populated from sys.sql_modules.
list_procedures¶
Targets: Data Warehouse / SQL Analytics Endpoint
List stored procedures on a warehouse or SQL Analytics Endpoint, optionally filtered to a single schema.
Parameters:
workspace(str): workspace name or GUID.item(str): warehouse or SQL analytics endpoint name or GUID.schema(str | null, optional): when provided, only procedures in this schema are returned.
Returns: list[StoredProcedure]: array of procedure objects, each with schema_name, name, qualified_name, created, and modified.
transfer_procedure¶
Targets: Data Warehouse / SQL Analytics Endpoint
Move a stored procedure to another schema via ALTER SCHEMA ... TRANSFER OBJECT::.... Supported on both Fabric Data Warehouses and SQL Analytics Endpoints; unlike transfer_table, no endpoint guard is applied here.
Definition text is not rewritten
ALTER SCHEMA ... TRANSFER moves the procedure, but it does not rewrite
the schema name inside the object's stored definition
(sys.sql_modules.definition, OBJECT_DEFINITION()). After a transfer,
get_procedure may still show the old schema name in the CREATE ... AS
header, even though the procedure now lives in the new schema. This tool does
not rewrite the definition text: doing so would require parsing and
regenerating SQL, which this project deliberately avoids. See
ALTER SCHEMA (Transact-SQL).
Parameters:
workspace(str): workspace name or GUID.item(str): warehouse or SQL analytics endpoint name or GUID.qualified_name(str): current dot-separated qualified procedure name, e.g.dbo.usp_load.target_schema(str): schema to move the procedure into, e.g.archive.
Returns: StoredProcedure: the moved procedure record, fetched from the new schema.
update_procedure¶
Targets: Data Warehouse / SQL Analytics Endpoint
Redefine a stored procedure via CREATE OR ALTER PROCEDURE.
Caution
body is executed verbatim as DDL. Ensure the body matches the user's intent before calling this tool.
Parameters:
workspace(str): workspace name or GUID.item(str): warehouse or SQL analytics endpoint name or GUID.qualified_name(str): dot-separated qualified procedure name, e.g.dbo.usp_load.body(str): the new procedure body (theAS …section).
Returns: StoredProcedure: the updated procedure object.