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
CodePudding user response:
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