Solved

Copy View Between SQL Server Databases

Posted on 2007-04-11
3
2,545 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
  • 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL LINE CONTINUATION ISSUE 12 31
MS SQL tables, .net application and ETL connundrum 3 53
Attaching Database Failed ? 3 37
Find results from sql within a time span 11 29
Creating and Managing Databases with phpMyAdmin in cPanel.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

815 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now