Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Copy View Between SQL Server Databases

Posted on 2007-04-11
3
Medium Priority
?
2,571 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

670 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