Jump to content

Search Among Several Sql Databases


Matteo
 Share

Recommended Posts

I am looking for a script or query that will allow for a common keyword search across several databases and return one consolidated recordset. Has anyone ever done something similar, do you have any ideas on how to create the necessary coding?The only solution I can think of atm is to create a separate database that has a single table to hold the query results from each database query request, but I am hoping there is a more seksi, i.e. streamlined approach.

Link to comment
Share on other sites

using SQL Server, you can query multiple databases provided that they are all on the same SQL Server. If multiple SQL servers are involved, you'd need to set them up as linked and then should be able to do the samei.e. select top 1 accountid from database1.dbo.table1unionselect top 1 accountid from database2.dbo.table1

Edited by aalbetski
Link to comment
Share on other sites

using SQL Server, you can query multiple databases provided that they are all on the same SQL Server. If multiple SQL servers are involved, you'd need to set them up as linked and then should be able to do the samei.e. select top 1 accountid from database1.dbo.table1unionselect top 1 accountid from database2.dbo.table1
Ok, I'll try that. Thanks.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...