views:

91

answers:

3

I have 2 totally separate databases - one MSSQL and one Pervasive. Due to the way our product data is stored in the Pervasive database, you cannot easily run a query to get a products's information and features to display on our website.

So, using a DTS package I take the product data from Pervasive and process it so it is one MSSQL table with the product item # (primary key for both databases) and all of the columns for the product features. Very easy and fast to query for our website.

The Pervasive database is the one used by the ERP system, so it always has the most up-to-date inventory totals for each product. Now, I need to find the best way to most efficiently pull the inventory information from the Pervasive database based on the records retrieved from the MSSQL database on a real-time basis.

Getting just one product's inventory information is no big deal. My main concern is how to pull inventory data for a list of items returned from a query on the MSSQL product table and have the inventory data match up with the correct items.

Caching all of the inventory data from the Pervasive db won't work because I need it to be real-time.

What are the most efficient options for me to pull this data, besides generating SELECT statements for each item in the list? I would like it to only be one database call if possible.

Thanks.

A: 

Could you keep a cache in MSSQL and have Pervasive update it using a trigger when the inventory level changes?

mopoke
Good idea, but I don't think I have access to add triggers to the Pervasive database.
NinjaBomb
+1  A: 

In order to access data to a different database from SQL Server, you'd have to first create a linked server instance on SQL Server pointing to the other db (Pervasive in this example) with appropriate credentials/permissions. This article is for linking MySQL to SQL Server 2008, but the steps are the same.

Once that's in place, you can write queries in SQL Server as though you were dealing with a single database.

OMG Ponies
I should have been more clear in the question. I don't need to write the inventory information from the Pervasive db to the MSSQL db, just pull it to process and display what I need to on the website. Actually, it's called Elliott. :o)
NinjaBomb
Eliot, eh? Only products I've seen use Pervasive were Sage (accounting) and AutoCAD
OMG Ponies
It was called Macola before that.
NinjaBomb
A: 

I'm not quite sure if this is applicable, but in MySQL, I've used the IN operator for pulling significant sets of data (up to thousands) at once.

SELECT a,b,c FROM table WHERE id IN (123,234,345,456,...)

It can at times really reduce the number of queries that need sent.

gahooa