[dba-SQLServer] Automating the creation of views

Powlen, Betsy Betsy.Powlen at stanleyassociates.com
Thu Apr 23 08:33:03 CDT 2009


Hi Stu,
It sounds to me like you want to copy certain views to your new
database. Is this correct? If so, you can use Data Transformation
Service (DTS) from Enterprise Manager. With this, you can export
whatever views you need and the dependant objects all in one action.
Betsy
 

-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of
sdunlap at brownshoe.com
Sent: Thursday, April 23, 2009 9:21 AM
To: dba-sqlserver at databaseadvisors.com
Subject: [dba-SQLServer] Automating the creation of views

Hi,

I'm new to SQL Server and I've been tasked with creating a lot of views
(over 100).  I'm using SQL Server 2005.

The process of creating these views will be repetitive, and I'm
wondering if there is some way to automate the creation of the views.

More details on the task at hand...I have a whole bunch of views in a
database, View1, View2, View3 ....... ViewN.  For the purposes of this
example, this database would be called 'OriginalDatabase'.

In another database, the views I need to create will be:    SELECT  *
FROM 
 OriginalDatabase.dbo.ViewX

In the SQL above, ViewX represents the view 1, 2, 3 or N.  I would want
to be able to generate the list of Views (1, 2, 3 ... N) by
programmatically reading the available views in the OriginalDatabase
views folder and selecting only the views I need based on a naming
convention - specifically, the first three characters of the view name =
'nnn'.

I have a book on SQL Server 2005, but I haven't been successful using
the index to find help on this, mainly because I'm not sure what topic
this would fall under. 

Does anyone know if it is possible to automate the creation of the
views?

Any insight is appreciated.

Thanks,
Stu
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com





More information about the dba-SQLServer mailing list