Solved

Copy View Between SQL Server Databases

Posted on 2007-04-11
3
2,566 Views
Last Modified: 2008-03-12
I am trying to find the SQL that will allow me to programmatically copy a view from one database to another.
0
Comment
Question by:Howard Bash
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 13

Expert Comment

by:Wizilling
ID: 18892801
right click the view and select modify in Query Analyser (sql 2000)  or SQL Management Studio (sql 2005)
after the view is opened in a query window, change the word ALTER at the top few lines to the word CREATE.
change your connection to the other server / database.
press F5 or play button to execute the create view statement.
0
 
LVL 1

Author Comment

by:Howard Bash
ID: 18898177
Let me reiterate,  I want to "programmatically" copy a view.  What you are suggesting is using SQL Server tools.  The question is not how to format a Create View command or Alter View.

Thanks.
0
 
LVL 1

Accepted Solution

by:
Howard Bash earned 0 total points
ID: 18898221
Also,  the following snippet would retrieve the View's DDL as most likely the only way to achieve the view copy :

 sSQL = "select text From syscomments WHERE id = (SELECT id FROM sysobjects WHERE name = '" & sViewName & "')"


0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question