views:

18

answers:

2

I am sure this is a simple question, but I am having no luck getting it answered.

I have a number of views in a MS SQL 2008 database I am now supporting but I am not able to find how to access the queries that define the views. I need to see that to get a list of all tables and databases the views are accessing.

A: 

Right-click on your view in the Object Explorer and select Design. If you do not see the SQL, then click the SQL button (likely 3rd button from the left) on the toolbar.

You can also right-click and select Script View as/Create To/New Query Editor Window.

RedFilter
+3  A: 

several ways, right click on the view and select SCRIPT View AS-->CREATE TO--> New Query Window (see picture below) , don't click design because the designer doesn't support CASE and other statements

or

sp_helptext 'ViewName'

or

select object_definition(object_id('ViewName'))

or

select name, object_definition(object_id) 
from sys.views
where name = 'ViewName'

'

alt text

SQLMenace
Thanks, I had a feeling I was missing rights and was not setup correctly. I was unable to see run these due to restrictions, and this helped me figure out what rights I needed.
zk

related questions