tags:

views:

31

answers:

4

I have a view which if i try to edit, MS SQL Server Management Studio crashes (the view contains a pivot function).

Is there a way i can view the sql that is inside the view without crashing MS SQL Server Management Studio?

+2  A: 

TRY:

exec sp_helptext yourViewName
KM
A: 

Found it, right click, Create to, Clipboard...

+1  A: 

Try this query - work on SQL Server 2005 and up:

SELECT
    v.name ,
    m.definition 
FROM 
    sys.views v
INNER JOIN 
    sys.sql_modules m ON v.object_id = m.object_id
marc_s
where v.name ='yourViewName'
KM
@KM: yes, sure - for a single view. Otherwise you'll get all views
marc_s
+1  A: 

What version of SQL Management Studio?

In 2008 I do the following:

Right click on the view

Select "Script view as..."

"Create to..." or "Alter to..."

"New query window"

Hogan