Functions¶
Manage T-SQL user-defined functions on Microsoft Fabric Data Warehouses and SQL Analytics Endpoints.
Targets: Data Warehouse · SQL Analytics Endpoint
CLI¶
functions create¶
Targets: Data Warehouse · SQL Analytics Endpoint
Create a new T-SQL user-defined function. Scalar UDFs and inline TVFs are preview features.
Synopsis
| Option | Description |
|---|---|
--name SCHEMA.FN |
Required. Qualified function name (e.g. dbo.fn_clean_input). |
--body TEXT |
Inline function body (parameter list, RETURNS clause, and implementation). |
--from-file PATH |
Path to a .sql file containing the function body. |
Exactly one of --body or --from-file must be provided.
Example
fdw -w MyWorkspace functions create SalesWH \
--name dbo.fn_clean_input \
--body "(@input NVARCHAR(100)) RETURNS NVARCHAR(100) AS BEGIN RETURN LTRIM(RTRIM(@input)) END"
functions drop¶
Targets: Data Warehouse · SQL Analytics Endpoint
Drop a T-SQL user-defined function. You will be asked to confirm unless --yes is passed.
Synopsis
| Option | Description |
|---|---|
--if-exists |
No-op when the function does not exist (DROP FUNCTION IF EXISTS). |
Example
functions get¶
Targets: Data Warehouse · SQL Analytics Endpoint
Get the full definition of a single T-SQL user-defined function, including its parameter list.
Synopsis
QUALIFIED_NAME must be a dot-separated schema.fn_name string, e.g. dbo.fn_clean_input.
Example
functions list¶
Targets: Data Warehouse · SQL Analytics Endpoint
List T-SQL user-defined functions on a warehouse or SQL Analytics Endpoint. Pass --schema to filter by schema, or --kind to filter by function kind.
Synopsis
| Option | Description |
|---|---|
--schema TEXT |
Only list functions in this schema. |
--kind [scalar\|inline-tvf\|all] |
Filter by function kind: scalar (FN), inline-tvf (IF), or all (default). |
Example
schema_name name kind is_inlineable created modified
------------ -------------- ------- -------------- --------------------- ---------------------
dbo fn_clean_input scalar True 2026-06-01T08:00:00Z 2026-06-10T12:00:00Z
functions rename¶
Targets: Data Warehouse · SQL Analytics Endpoint
Rename a T-SQL user-defined function via EXEC sp_rename. The new name must be a bare (unqualified) identifier — sp_rename cannot move a function to a different schema. You will be asked to confirm unless --yes is passed.
Synopsis
| Option | Description |
|---|---|
--new-name TEXT |
Required. New bare (unqualified) function name. |
Example
functions update¶
Targets: Data Warehouse · SQL Analytics Endpoint
Redefine an existing T-SQL user-defined function via CREATE OR ALTER FUNCTION.
Note
ALTER FUNCTION cannot change the function kind (e.g. scalar to inline TVF). The body must be compatible with the original function's kind.
Synopsis
QUALIFIED_NAME is the dot-separated schema.fn_name to update.
| Option | Description |
|---|---|
--body TEXT |
Inline function body. |
--from-file PATH |
Path to a .sql file containing the function 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 functions update SalesWH dbo.fn_clean_input \
--from-file ./fns/fn_clean_input_v2.sql
MCP tools¶
create_function¶
Targets: Data Warehouse · SQL Analytics Endpoint
Create a new T-SQL user-defined function. Scalar UDFs and inline TVFs are preview features.
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 function name, e.g.dbo.fn_clean_input.body(str) — the function body (parameter list, RETURNS clause, and implementation).
Returns: FunctionDetails — the newly-created function object.
drop_function¶
Targets: Data Warehouse · SQL Analytics Endpoint
Drop a T-SQL user-defined function.
Parameters:
workspace(str) — workspace name or GUID.item(str) — warehouse or SQL Analytics Endpoint name or GUID.qualified_name(str) — dot-separated qualified function name, e.g.dbo.fn_clean_input.if_exists(bool, optional) — whentrue, emitsDROP FUNCTION IF EXISTS(no-op when function does not exist). Defaults tofalse.
Returns: { "dropped": true } — confirmation.
get_function¶
Targets: Data Warehouse · SQL Analytics Endpoint
Fetch the full definition of a single T-SQL user-defined function, including its parameter list.
Parameters:
workspace(str) — workspace name or GUID.item(str) — warehouse or SQL Analytics Endpoint name or GUID.qualified_name(str) — dot-separated qualified function name, e.g.dbo.fn_clean_input.
Returns: FunctionDetails — single function object with definition (from sys.sql_modules) and parameters (from sys.parameters).
list_functions¶
Targets: Data Warehouse · SQL Analytics Endpoint
List T-SQL user-defined functions on a warehouse or SQL Analytics Endpoint, optionally filtered by schema or kind.
Parameters:
workspace(str) — workspace name or GUID.item(str) — warehouse or SQL Analytics Endpoint name or GUID.schema(str | null, optional) — when provided, only functions in this schema are returned.kind(str, optional) — filter by function kind:"scalar"(FN only),"inline-tvf"(IF only), or"all"(FN + IF + TF, the default).
Returns: list[Function] — array of function objects, each with schema_name, name, qualified_name, kind, is_inlineable, created, and modified.
rename_function¶
Targets: Data Warehouse · SQL Analytics Endpoint
Rename a T-SQL user-defined function via sp_rename. The new name must be a bare (unqualified) identifier — sp_rename cannot move a function across schemas.
Parameters:
workspace(str) — workspace name or GUID.item(str) — warehouse or SQL Analytics Endpoint name or GUID.qualified_name(str) — current dot-separated qualified function name, e.g.dbo.fn_clean_input.new_name(str) — new bare function name (no schema prefix), e.g.fn_sanitize_input.
Returns: FunctionDetails — the renamed function record.
update_function¶
Targets: Data Warehouse · SQL Analytics Endpoint
Redefine a T-SQL user-defined function via CREATE OR ALTER FUNCTION.
Note
ALTER FUNCTION cannot change the function kind (e.g. scalar to inline TVF). The body must be compatible with the original function's kind.
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 function name, e.g.dbo.fn_clean_input.body(str) — the new function body (parameter list, RETURNS clause, and implementation).
Returns: FunctionDetails — the updated function object.