Viewing Object Definitions

The rules for viewing the Transact-SQL source code of database objects are stricter than for viewing metadata. To see the Transact-SQL definition of an object, a user must either own the object or have been granted one of the following permissions on the object:





The following are some examples of how these rules work:

  • If a user is granted ALTER permission on a table myTable, the user can see the Transact-SQL definition of the subcomponents that are related to the table in the definition column in each of the catalog views that are listed in the following table. If a user does not have one of the previous permissions or does not own the object, the Transact-SQL definition in the definition column of the catalog view is NULL.

  • If the user is not the table owner of myTable and has been granted only SELECT permission on the table, when the user accesses the following catalog views, the definition columns are NULL.

    Catalog view name

    Transact-SQL definitions for


    All triggers in mytable


    All computed column in myTable


    All CHECK constraints in myTable


    All DEFAULT constraints in myTable

  • Assume that a user is granted EXECUTE permission on the procedure myProcedure. When the user tries to see the Transact-SQL definition of the procedure by accessing the sys.sql_modules catalog view, the definition column has a null value. Conversely, if the user has been granted TAKE OWNERSHIP permission on myProcedure, the user will see the Transact-SQL definition of the procedure in the definition column of sys.sql_modules.