开发者

Display contents of TSQL view

开发者 https://www.devze.com 2022-12-20 20:08 出处:网络
I have a view which if i try to edit, MS SQL Server Management Studio crashes (the view contains a pivot function).

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...

0

精彩评论

暂无评论...
验证码 换一张
取 消