在 SQL 2005 上从生产环境创建开发环境

发布于 2024-09-16 19:45:15 字数 86 浏览 2 评论 0原文

我创建了一个新数据库(从生产数据库开发)。这些数据库具有不同的名称,现在我的过程中的插入和更新语句都以生产数据库名称为前缀。我怎样才能改变这个而不是手动做呢?

I have created a new database(development from production DB). These DBs have different names and now insert and update statements in my procedures are prefixed with the production database name. How can i change this rather than doing it mannually.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

只等公子 2024-09-23 19:45:15

将程序和函数编写成脚本,然后在文本文件中搜索和替换,然后应用到新数据库?您可以轻松地实现所有这些自动化。

Script the procedures and functions out and then search and replace in the text file, and then apply to the new db? You can automate all of that easily.

烟酉 2024-09-23 19:45:15

我认为普雷特的做法是正确的。这是一种理论上应该可行的方法(尽管我自己没有尝试过)。

您可以通过单击 SSMS 中的“存储过程”节点编写所有过程的脚本,然后从“对象资源管理器详细信息”窗格(“视图”菜单)中选择所有过程。右键单击并选择将存储过程编写为“创建到新查询窗口”(令人烦恼的是,您无法选择“更改”)。进行搜索替换并将“CREATE PROC”更改为“ALTER PROC”。现在进行搜索和替换,以找出所有不正确的数据库引用。然后运行查询...

祝你好运!

I think that Preet has the right approach. Here is a way that should work in theory (although I've not tried it myself).

You could script out all your procedures by clicking on the Stored Procedures node in SSMS, then from the Object Explorer Details pane (View menu) you can select them all. Right click and choose Script Stored Procedure as CREATE To New Query Window (annoyingly you can't choose ALTER). Do a search replace and change "CREATE PROC" to "ALTER PROC". Now do your search and replace to sort out all the incorrect database references. Then run the query...

Good luck!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文