Sql Query to list all views in an SQL Server 2005 database

155,891

This is old, but I thought I'd put this out anyway since I couldn't find a query that would give me ALL the SQL code from EVERY view I had out there. So here it is:

  SELECT SM.definition
  FROM sys.sql_modules SM
  INNER JOIN sys.Objects SO ON SM.Object_id = SO.Object_id
  WHERE SO.type = 'v'
Share:
155,891
Mats
Author by

Mats

Updated on November 16, 2020

Comments

  • Mats
    Mats over 3 years

    I need an sql query to enumerate all views (I only need the view names) of a specific database in SQL Server 2005. Thanks in advance!