开发者

How to see the query that defines a view in SQL 2008

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 h开发者_高级运维ow 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.


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'

'

How to see the query that defines a view in SQL 2008


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜