March 6, 2007 at 10:14 am
How do I do, from a single SQL server, to create a list of the names of all active database/SQL server without using the linked server technique?
For instance, I have 10 production SQL servers, and 10 test/dev servers. Could I come up with a list of all production database/server names and another list of all test database/server names?
March 6, 2007 at 10:33 am
i have this procedure that i use; sorry i don't know the source of where i got it: this lists all servers on the network, you'd then need to query each server for the db's it hosts...assuming you have a login that works on every server.
CREATE PROCEDURE dbo.ListLocalServers
AS
BEGIN
SET NOCOUNT ON
CREATE TABLE #servers(sname VARCHAR(255))
INSERT #servers EXEC master..XP_CMDShell 'OSQL -L'
-- play with ISQL -L too, results differ slightly
DELETE #servers WHERE sname='Servers:'
SELECT LTRIM(sname) FROM #servers WHERE sname != 'NULL'
DROP TABLE #servers
END
EXEC ListLocalServers
results:
(local)
ASTRAH
AURORA
BELLE
etc....
Lowell
March 6, 2007 at 11:27 am
Thanks.
Basically it is the list of DB names within the entire network SQL servers I am looking for. Ideally I'd like to see the possible [one-shot] way of getting the DB listing of the servers within a given network/domain.
March 7, 2007 at 12:36 am
Once you have the server name it should be possible to query the sysdatabases DB and get the DB-List for each server
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply