SQL Flow Field Guide

SCHEMA_NAME

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

catalog lookup

What changes

Input
catalog metadata (object, column, index, file, database properties)
Output or change
id, name or property value
Return type
sysname Returns NULL when schema_id is not a valid ID.

Syntax at a glance

SCHEMA_NAME ( [ schema_id ] )

Work example

Display the schema name for a visible schema identifier.

Use schema-qualified names in scripts to avoid relying on a user's default schema.

Check your work SCHEMA_NAME with no argument returns the caller's default schema name.

Practice SQL

Open in SQL Flow
SELECT SCHEMA_NAME() AS default_schema;

Open Microsoft Learn for full syntax, permissions, and details for your version.