sp_checksource

Checks for the existence of the source text of compiled objects such as views, defaults, rules, triggers, procedures, declarative defaults, check constraints, computed columns, function-based indexes and predicates. The predicate name may be a user-defined or internal name.

Syntax

sp_checksource [objname [, tabname [, username]]]

Parameters

Examples

Usage

There are additional considerations when using sp_checksource:
  • sp_checksource checks for the existence of the source text of the specified compiled object. If the source text exists for the specified object, sp_checksource returns 0. If the source text does not exist for the specified object, sp_checksource returns 1.

  • If you do not provide any parameters, sp_checksource checks the existence of the source text for all compiled objects in the current database.

  • To use sp_checksource with no parameters, you must be the database owner or system administrator.

  • sp_checksource encrypts the text of user-defined functions.

Permissions

The permission checks for sp_checksource differ based on your granular permissions settings.

SettingDescription
Enabled

With granular permissions enabled, you must be a user with manage database privilege to check for the existence of the source text of compiled objects that are owned by another user.

Any user can execute sp_checksource to check for the existence of the source text for his or her own compiled objects.

Disabled

With granular permissions disabled, you must be the database owner or a user with sa_role to check for the existence of the source text of compiled objects that are owned by another user.

Any user can execute sp_checksource to check for the existence of the source text for his or her own compiled objects.

Auditing

Values in event and extrainfo columns from the sysaudits table are:

InformationValues
Event

38

Audit option

exec_procedure

Command or access audited

Execution of a procedure

Information in extrainfo
  • Roles – Current active roles

  • Keywords or options – NULL

  • Previous value – NULL

  • Current value – NULL

  • Other information – All input parameters

  • Proxy information – Original login name, if set proxy in effect

Related reference
sp_hidetext