Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run query against multiple databases

Status
Not open for further replies.

katehol

Technical User
May 2, 2007
57
GB
I have to run a script I have written against multiple databases (about 40) - how would I do this? Once I have the results I need them all to be unioned into one table.

Part of the script is below...

Thanks for any help.

:)

Code:
USE db1

SELECT * FROM Users
WHERE (Users.user_type = '1.0' AND Users.user_id <> 'itadmin')
OR (Users.user_id LIKE '%test%' OR Users.user_forename LIKE '%test%' OR Users.user_surname LIKE '%test%')
 
For a start, take a look at FAQ183-4107

-SQLBill

Posting advice: FAQ481-4875
 
Thanks for that - am now a bit further on... Have got it all working to bring back the individual results, but how can I union all of those results together?
Thanks
K :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top