Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Database names from multiple SQL Servers

I am stuck with a SQL query. How do I get all the databases names from multiple SQL Servers at a time? I have the server IP's in a table.

like image 660
Karbas Avatar asked Apr 13 '26 18:04

Karbas


1 Answers

You can get the database informations using.

SELECT * from sys.databases

If you want to know this from other servers, in pure t-sql, you need to link the server.

More Information

  • MSDN - Linking Servers
  • MSDN - sp_addlinkedserver (Transact-SQL)

Update after a comment

You say that you cant link the servers. Another alternative is to create a .NET CLR Object and embed them to the server.

Than you can connect to other servers, without linking them together, and execute sql statements.

More Information

  • MSDN - Using CLR Integration in SQL Server 2005
like image 126
dknaack Avatar answered Apr 16 '26 07:04

dknaack



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!