database view - get code

Dear, how can I see the code to create a database view? For example, I have a UsrVwContactAddress view and I would like to get the creation code for that view in sql console:

CREATE VIEW dbo.UsrVwContactAddress
AS
SELECT...

 

Thanks!

Like 0

Like

2 comments

Hi Sebastian, 

 

Here are the example how you can do it:

 

 

Best Regards, 

 

Bogdan L

If this is a cloud system, and you don't have access to local tools, you can use the following commands via SQL Executor to get the SQL for the view.

If database is MSSQL:

SELECT
    definition
FROM
    sys.sql_modules
WHERE
    object_id = object_id('viewname');

If database is Postgresql:

select pg_get_viewdef('"viewname"', true)

Ryan

Show all comments