May 14, 2008 at 1:23 pm
Hi,
I want to script out the views in a database using t-sql script. Can someone help me on this?
Also, what permissions are required in order to view the views definition in a database?
Thanks in advance,
Manu
May 14, 2008 at 1:48 pm
Right-click on the View and select Script VIEW as > and make the appropriate selections in the next menu.
I'm not positive but I assume at least DBO rights are necessary. If you have sysadmin rights, you already have what you need.
May 14, 2008 at 1:58 pm
Thanks Jim. But I need to generate script using query analyzer.
Manu
May 14, 2008 at 2:10 pm
It is really the same in Query Analyzer. Right-click on the view and make the appropriate scripting selection and destination.
May 14, 2008 at 2:19 pm
You can select data from INFORMATION_SCHEMA.VIEWS to use in your script.
Greg
May 14, 2008 at 2:34 pm
You can also use sp_helptext and store the results in a variable for output. And, depending if you're using SQL 2000 or 2005, you can use the following:
-- SQL 2005
select definition from sys.sql_modules
where object_name( object_id ) = 'vw1'
-- SQL 2000
select text from sys.syscomments
where id = object_id ( 'vw1' )
DAB
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply