Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy views from one database to another in the same server 2

Status
Not open for further replies.

shanghai2004

Programmer
Dec 16, 2004
37
CA
Dear Expert,

I need to copy all views from one database to another in the same SQL server. Can I create a SQL program to do it?
If I pick all view names from sysobjects table, how do I avoid picking the system views?

Thanks


 
Go into enterprise manager to the db where the views exist. Select all the views you want to copy. Right click and choose All Tasks -->> Generate SQL script. Click on preview. Click on Copy. You can then paste the script into query analyzer and run it.

Jim
 
Hi Jim,

Follow your instructions I copied Views successfully from one database to another. But when I tried to copy Stored Procedures I got many messages like the following:

Cannot add rows to sysdepends for the current stored procedure because it
depends on the missing object 'ITAUTOASGNCOND'. The stored procedure will
still be created.

The numbers of procedures in both databases are the same. But the numbers of rows in sysdepends table are not equal in two databases. Do I need to worry about the sydepends table?

I guess it may relate to the order of the Stored Procedures that I create. Should I need to change the script file generated to make it in right order? If yes, is there an easy way to find the right order?

Thanks


Winnie
 
Hi Denis,

I think that 'run the script twice for the procs' does not solve my problem because there are drop procedure statements in the script. Also all the drop statements are executed before executing create procedures statements.
If I do not drop a procedure will SQL lets me create a new procedure with the same name?


Thanks

Winnie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top