SQL Flow Field Guide

sys.sp_validname

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

Checks for valid SQL Server identifier names.

What changes

Input
Checks for valid SQL Server identifier names.
Output or change
No write is stated in the Microsoft summary.

Syntax at a glance

sys.sp_validname
    [ @name = ] N'name'
    [ , [ @raise_error = ] raise_error ]
[ ; ]

Work example

Checks for valid SQL Server identifier names.

Write a proposed call on paper. Name the target, required permission, expected change, and recovery step before any lab use.

Check your work Returns validation_code 0 for this valid identifier. Microsoft documents public role membership as sufficient.

Practice SQL

Open in SQL Flow

Open the SQL for a walkthrough. Run the example in SQL Server to check its result.

DECLARE @return_code int; EXEC @return_code = master.sys.sp_validname @name = N'SalesOrder2026'; SELECT @return_code AS validation_code;

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