sys.sql_modules (Transact-SQL)

Returns a row for each object that is a SQL language-defined module. Objects of type P, RF, V, TR, FN, IF, TF, and R have an associated SQL module. Stand-alone defaults, objects of type D, also have a SQL module definition in this view.

Column name Data type Description

object_id

int

ID of the object of the containing object. Is unique within a database.

definition

nvarchar(max)

SQL text that defines this module.

NULL = Encrypted.

uses_ansi_nulls

bit

Module was created with SET ANSI_NULLS ON.

Will always be = 0 for rules and defaults.

uses_quoted_identifier

bit

Module was created with SET QUOTED_IDENTIFIER ON.

is_schema_bound

bit

Module was created with SCHEMABINDING option.

uses_database_collation

bit

1 = Schema-bound module definition depends on the default-collation of the database for correct evaluation; otherwise, 0. Such a dependency prevents changing the database's default collation.

is_recompiled

bit

Procedure was created WITH RECOMPILE option.

null_on_null_input

bit

Module was declared to produce a NULL output on any NULL input.

execute_as_principal_id

int

ID of the EXECUTE AS database principal.

NULL by default or if EXECUTE AS CALLER.

ID of the specified principal if EXECUTE AS SELF or EXECUTE AS <principal>.

-2 = EXECUTE AS OWNER.

Remarks

The SQL expression for in-line defaults is found in the sys.default_constraints catalog view. The SQL expression for an in-line CHECK constraint is found in the sys.check_constraints catalog view.

See Also

Reference

Catalog Views (Transact-SQL)
Object Catalog Views (Transact-SQL)

Other Resources

Querying the SQL Server System Catalog FAQ

Help and Information

Getting SQL Server 2005 Assistance