MS SQL Server Concepts and Programming Question:
Download Questions PDF

How To Generate CREATE VIEW Script on an Existing View?

Answer:

If you want to know how an existing view was created, you can use SQL Server Management Studio to automatically generate a "CREATE VIEW" script The following tutorial shows you how to do this:

1. Run SQL Server Management Studio and connect to SQL server.

2. On the Object Explorer window, follow the object tree: Databases > GlobalGuideLineDatabasee > Views > dbo.ggl_links_top.

3. Click right mouse button on dbo.ggl_links_top. The context menu shows up.

4. Select "Script Table as" > "CREATE to" > "New Query Editor Window". The following script will be displayed:

USE [GlobalGuideLineDatabasee]
GO
<pre>/****** Object: View [dbo].[ggl_links_top]
Script Date: 05/19/2007 15:07:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[ggl_links_top] AS
SELECT id, counts, url FROM ggl_links
WHERE counts > 100;</pre>

Download MS SQL Server Interview Questions And Answers PDF

Previous QuestionNext Question
How To Get a List of Columns in a View using the "sp_help" Stored Procedure?How To Get the Definition of a View Out of the SQL Server?