Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sql Server - Get view creation statement for existing view

Tags:

sql-server

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.

like image 456
rosscj2533 Avatar asked Dec 07 '09 19:12

rosscj2533


People also ask

Can a view be derived from another view?

Views can be created from a single table, multiple tables or another view.

Can we call a view from a view in SQL Server?

Using views to reference other views is perfectly acceptable. The performance will greatly depend on your code, though.

How do I find the schema of a SQL view?

You can get a list of the schemas using an SSMS or T-SQL query. To do this in SSMS, you would connect to the SQL instance, expand the SQL database and view the schemas under the security folder. Alternatively, you could use the sys. schemas to get a list of database schemas and their respective owners.


2 Answers

Right click on the view and script it.

like image 118
HLGEM Avatar answered Oct 21 '22 12:10

HLGEM


Have you had a look at sp_helptext?

sp_helptext 'dbo.name_of_view'

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

like image 36
Adriaan Stander Avatar answered Oct 21 '22 14:10

Adriaan Stander