Click here to Skip to main content
15,885,881 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I have 2 databases.
Each database contains a Table named MyTable with the following fields
ID (Numeric, unique values)
Comments (Text)
Img (Binary field)
In the first database (DBEven), there are only even IDs in MyTableEven
In the second database (DBOdd), there are only odd IDs in MyTableOdd
I cannot work with a unique database because the total size of the data exceed 2 GB.

I want to use a UNION QUERY to group these 2 tables in a unique recordset.
Since it is not possible to use UNION with binary fields, I have written the successive queries :

1. STEP : Attach MyTableEven in DBodd . It will be easier to continue ...

2. STEP : Creating the RecorsetUnion without the binary fields
RecordsetUnion = SELECT MyTableOdd.ID, MyTableOdd.Comments FROM MyTableOdd UNION SELECT MyTableEven.ID, MyTableEven.Comments FROM MyTableEven

3. STEP : Adding the OLE data from MyTableOdd
RecordsetUnion2 = SELECT RecordsetUnion.ID, RecordsetUnion.Comments, MyTableOdd.Img FROM RecordsetUnion LEFT JOIN MyTableOdd ON RecordsetUnion.ID=MyTableOdd.ID;

4. STEP : Adding the OLE data from MyTableEven
RecordsetUnion3 = SELECT RecordsetUnion2.*, MyTableEven.Img FROM RecordsetUnion2 LEFT JOIN MyTableEven ON RecordsetUnion2.ID=MyTableEven.ID;


Though it's a bit long ... it works BUT in RecordsetUnion3, the OLE data extracted from MyTable Even are NOT in the same field than the OLE data coming from MyTableOdd

How could I get all the OLE data in the same field ???

Thank you for your help,

Philippe
Posted
Comments
CHill60 25-Nov-15 10:27am    
I don't understand your comment "I cannot work with a unique database because the total size of the data exceed 2 GB." - what version of SQL server are you using?
Have you considered storing the binary field as a file in a folder and just storing the (relative) path to the image on the database - far more efficient.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900