如何将视图从一个数据库复制到另一个数据库 [英] How to copy views from one database to another database

查看:119
本文介绍了如何将视图从一个数据库复制到另一个数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 MS SQL 服务器中有两个结构相同的数据库.

I have two databases with same structure in MS SQL server.

我想将所有视图复制到另一个数据库.

I'd like to copy all views another database.

我尝试使用 DTS 的导出数据功能(适用于表对象).

I tried to use Export data functionality by DTS (that works with the table objects).

但是那会执行 SQL &创建表对象.

But that executes the SQL & creates the table object.

我不想执行只是想复制视图以便我可以在设计视图中打开它们.

I don't want to execute that just want to copy the view so that I can open them in design view.

我尝试在目标数据库中创建新视图 &复制源数据库视图的SQL查询&保存视图.效果与我想要的完全一样,但我有很多观看次数&份数!

I tried to use create new view in destination database & copy SQL query of the view of the source database & save the view. That works works exactly same that I want, But I have number of views & number of copies!

推荐答案

右键单击您的数据库并说 Tasks->Generate scripts.SQL Server Management Studio 能够为您生成 CREATE 脚本.

Right click on your database and say Tasks->Generate scripts. SQL Server Management Studio is able to generate the CREATE scripts for you.

然后你简单地复制这个脚本并在目标服务器/数据库上执行它.

Then you simple copy this script and execute it on the target server/database.

这篇关于如何将视图从一个数据库复制到另一个数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆