List of databases in servers

  • Hi I gto different servers whose names start with MSX like MSX001, MSX34, MSX674 and so on..

    Now i got to get a list of all the databases in that servers so is there any way that i can do it in a single query to get the list of databases in the servers starting with MSX or do i need to query individual server?

    Please help me out with this please.

  • you'll need to query each server, but the query is the same for each server:

    SELECT name FROM master.sys.databases where LEFT(name,3) = 'MSX'

    this is where you might want to consider a different tool, like powershell, which can query all the servers easier than doing it in SQL, where you have to get a list of servers, create linked servers for them and then query them.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply