Please let me start by saying I really don't know the syntax for SQL scripts when it comes to variables, loops, etc., so my example code I'm sure isn't close to what I need.
Could someone share with me the syntax to run a SQL script against an array/list of databases. So instead of doing:
I could do something along the lines of
Could someone share with me the syntax to run a SQL script against an array/list of databases. So instead of doing:
Code:
USE DB1
select count(*) from users
USE DB2
select count(*) from users
USE DB3
select count(*) from users
I could do something along the lines of
Code:
MyDB(1) = 'DB1'
MyDB(2) = 'DB2'
MyDB(3) = 'DB3'
Loop I = 1 to 3
USE MyDB(I)
select count(*) from users
end loop