KyleStranger
KyleStranger

Reputation: 241

Calling all database table names to create a list || pyodbc

I currently have an MSSQL server that has about 60 databases in it.

Does anyone know a way to list the database names with a for loop, so that I am able to access each table?

The structure should be something like this :

for each Database in Server    
  MyList{} = MyList + DatabaseName    
endfor

I can't seem to find any documentation that includes something like this

Upvotes: 0

Views: 571

Answers (1)

Gabio
Gabio

Reputation: 9494

You can query the sys tables in order to get all the objects in your server.

In order to get all the databases, run the following query:

SELECT name, database_id FROM sys.databases

Upvotes: 2

Related Questions