Checking view definition using the sp_helptext stored procedure
One of the easiest ways to check the view definition is by usingsp_helptext
stored procedure. The sp_helptext stored procedure returns the definition of the view.
To get the view’s definition, you need to pass the name of the view to the sp_helptext
stored procedure. For example, the following statement returns the definition of sales.product_catalog
view:
EXEC sp_helptext 'dbo.Vwemp';The following is the output of the above query.

Getting the view definition using OBJECT_DEFINITION() function
Another way to get the view definition is usingOBJECT_DEFINITION()
function. Here you have to use OBJECT_ID()
function along with OBJECT_DEFINTION()
function as follows:
SELECT OBJECT_DEFINITION ( OBJECT_ID ( 'dbo.Vwemp' ) ) view_info;The following output shows the result of the above statement.

Checking view definition using the sys.sql_modules catalog
Another alternate method to get the view definition using the systemcatalog sys.sql_modules
and the OBJECT_ID
function.
SELECT definition, uses_ansi_nulls, uses_quoted_identifier, is_schema_bound FROM sys.sql_modules WHERE object_id = object_id( 'dbo.Vwemp' );In the above query, you pass the view name to the
OBJECT_ID()
function which returns the identification number of the view to the sys.sql_modules
catalog.
Here is the output of the above query:

CTRL+T
or click the Result to Text button as shown in the following screenshot.
Summary: In this tutorial, you have learned various ways to check the view definition in SQL Server definition.