在多个数据库上执行SQL查询 [英] Executing SQL query on multiple databases

查看:179
本文介绍了在多个数据库上执行SQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我的帖子在该论坛中的标题与其他帖子的标题非常相似,但是我确实找不到我需要的答案。



这是我的问题,我在Windows Server上运行了一个SQL Server。在我的SQL Server中,我有大约30个数据库。它们都具有相同的表和相同的存储过程。



现在,问题来了,我有一个很大的脚本,需要在所有这些数据库中运行。我希望对所有数据库都只能做一次。



我尝试了几项操作,例如转到查看 >>注册的服务器>>本地服务器组>>新服务器注册。但是此解决方案适用于许多服务器,而不是许多数据库。



我知道我可以通过输入数据库名称来做到这一点,但是查询确实很大,因此需要花很多时间。



是否有人知道这样做是否可行?

解决方案



加载脚本和数据库时,只需单击执行按钮,然后等待结果:




I know my post has a very similar title to other ones in this forum, but I really couldn't find the answer I need.

Here is my problem, I have a SQL Server running on my Windows Server. Inside my SQL Server, I have around 30 databases. All of them have the same tables, and the same stored procedures.

Now, here is the problem, I have this huge script that I need to run in all of these databases. I wish I could do it just once against all my databases.

I tried a couple things like go to "view" >> registered servers >> local server groups >> new server registration. But this solution is for many servers, not many databases.

I know I could do it by typing the database name, but the query is really huge, so it would take too long to run in all databases.

Does anybody have any idea if that is possible?

解决方案

ApexSQL Propagate is the tool which can help in this situation. It is used for executing single or multiple scripts on multiple databases, even multiple servers. What you should do is simply select that script, then select all databases against which you want to execute that script:

When you load scripts and databases you should just click the "Execute" button and wait for the results:

这篇关于在多个数据库上执行SQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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