I have a view in SQL Server 2008 and would like to view it in Management Studio.
--is the underlying query for the view Example_1 select * from table_aView
How to get the query of the corresponding view table (query used to create the view)?
Thanks in advance
This question is tagged with
~ Asked on 2013-11-25 09:58:16
In Management Studio, open the Object Explorer.
Script view as > Create To > New query window
and you're done!
If you want to retrieve the SQL statement that defines the view from T-SQL code, use this:
SELECT m.definition FROM sys.views v INNER JOIN sys.sql_modules m ON m.object_id = v.object_id WHERE name = 'Example_1'
~ Answered on 2013-11-25 10:01:21
sp_helptext before the
Hence you will get the query:
CREATE VIEW dbo.Example_1 AS SELECT a, b, c FROM dbo.table_name JOIN blah blah blah WHERE blah blah blah
sp_helptext will give stored procedures.
~ Answered on 2017-09-20 18:40:40