Hello. I was hoping someone could help me with this, I can usually work this sort of thing out myself but I'm a bit stuck..
It's a work thing. We have a SQL Server with multiple databases, the schema of many being identical. I want to be able to easily query all of certain types of DB to get some information out. To elaborate...
Say the databases I'm interested in all end in 123_456, but they start with something else, (e.g. abc.123_456, def.123_456, etc etc)
Each of these databases contains a table called 'Parameters', and each 'Parameters' table contains a field called 'Version' (for sake or argument).
I want to be able to return lines from the 'Parameters' table where the 'Version' = 'XYZ'.
So my query needs to be something like: select * from Parameters where version = 'xyz'. What I don't know how to do is expand this to pick up the same info from all databases ending in 123_456. I'm assuming I can use something like UNION where DBName LIKE *.123_456, but I've struggled to get anywhere so far. I could be barking up the wrong tree so if there's a much better way please let me know!
It's a work thing. We have a SQL Server with multiple databases, the schema of many being identical. I want to be able to easily query all of certain types of DB to get some information out. To elaborate...
Say the databases I'm interested in all end in 123_456, but they start with something else, (e.g. abc.123_456, def.123_456, etc etc)
Each of these databases contains a table called 'Parameters', and each 'Parameters' table contains a field called 'Version' (for sake or argument).
I want to be able to return lines from the 'Parameters' table where the 'Version' = 'XYZ'.
So my query needs to be something like: select * from Parameters where version = 'xyz'. What I don't know how to do is expand this to pick up the same info from all databases ending in 123_456. I'm assuming I can use something like UNION where DBName LIKE *.123_456, but I've struggled to get anywhere so far. I could be barking up the wrong tree so if there's a much better way please let me know!