I found something that solves my problems.
SQL Server Management Studio 2008 has a feature called Registered Databases.
After registering the databases with their respective credentials, it is possible to run a script in all the databases at the same time.
For that reason:
- Open MSSMS and connect to any server, in my case it is the server called "LOCALDB";
- In the "Object Researcher" connect to other servers. "WEBDB" in my case;
- Right-click on one of the servers and choose "Register";
- Set the credentials and any name for the server and click Save;
- Do the same with other servers;
Now to run scripts on all at once just go to View > Registered Servers. Or press Ctrl+Alt+G.
Expand the "Database Engine", right-click on "Local Server Groups" > "New Query".
Note that if there is more than one server in the "Local Server Groups" the status bar of the script area will turn red indicating that the command will be executed on behalf of multiple logons.
The name of the banks on both servers must be the same and you must use the use command, i.e.:
use meuBancodeDados
select * from minhaTB
myBancodeDados must exist on the 2 servers or will be run only on the one that exists.
For more information:
http://msdn.microsoft.com/en-us/library/bb964743(v=sql.100). aspx
Thank you for the reply Thiago.
– Onaiggac
Hello Thiago. I found something better. See my answer.
– Onaiggac