[dba-SQLServer] Automating the creation of views

Robert L. Stewart robert at webedb.com
Fri Apr 24 14:00:25 CDT 2009


Stu,

When  you right click on a view, you can edit it.
When you edit it, you get the SQL script.
Change the alter to create.
Add the sourcedatabase. where you need to.
Right click on the view tab.
change the connection to the database you want to save it in.
Execute the SQL.

There is no way of automating it beyond that.


At 12:00 PM 4/24/2009, you wrote:
>Date: Fri, 24 Apr 2009 08:14:53 -0500
>From: sdunlap at brownshoe.com
>Subject: Re: [dba-SQLServer] Automating the creation of views
>To: dba-sqlserver at databaseadvisors.com
>Message-ID:
> 
><OFD1168E8D.6B19CFE9-ON862575A2.004635B7-862575A2.0048C780 at brownshoe.com>
>
>Content-Type: text/plain; charset="US-ASCII"
>
>Francisco / Betsy,
>
>Thank you both for your replies.  Francisco, I read the article you
>provided, but I'm still stuck.  I'm able to successfully transport the
>results of the View from the source database to a table in the target
>database using the SSIS wizard.
>However, what I want to do is take a view from the source database, such
>as:  "SELECT * FROM dbo.MySourceTable WHERE MyField = 'xxx'"
>
>and create a new view in the target database like this:   "SELECT * FROM
>SourceDatabase.dbo.MySourceTable WHERE MyField = 'xxx'"
>
>... or alternatively, I suppose it could be:  "SELECT * FROM
>SourceDatabase.dbo.MyView"
>
>Does anyone know of a way to have the view copied into the target database
>as a view?
>
>Thanks,
>Stu





More information about the dba-SQLServer mailing list