Display contents of TSQL view
I have a view which if i try to edit, MS SQL Server Management Studio crashes (the view contains a pivot function).
Is there 开发者_StackOverflow社区a way i can view the sql that is inside the view without crashing MS SQL Server Management Studio?
TRY:
exec sp_helptext yourViewName
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
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"
Found it, right click, Create to, Clipboard...
精彩评论