views:

150

answers:

4

Is there a way to get the statement that created a view for an existing view in SQL Server 2008? I thought there was a stored procedure or some metadata that had this data, but I'm not finding anything.

+2  A: 

Right click on the view and script it.

HLGEM
This also works just as good as the accepted answer, thanks.
rosscj2533
+3  A: 

Have you had a look at sp_helptext?

SQL SERVER – Stored Procedure to display code (text) of Stored Procedure, Trigger, View or Object

astander
Yes, this is what I was thinking of, thank you.
rosscj2533
+1  A: 

It's in sys.sql_modules. Other schema tables like INFORMATION_SCHEMA ones only contain the first 4000 characters of the definition (they truncate).

Remus Rusanu
This would be my answer...
gbn
A: 

Check out this

brian