how to create a report with data from duatabase on the same server or different servers, using SQL Server 2000, using the crystal report 8.5 or **data report of VB6 **

For example I have table A and table B with the same table structure, table A is stored in the database with the name DataB1 and stored in a database table B DataB2

Table A
code name

Jon X1
Jim X2

Table B
code name

Yana Y1
Y2 yono

I want to create a report showing the contents of both tables A and B
Dapa contained two different databases, which ultimately results

Combined table A and table B into
code name

Jon X1
Jim X2
Yana Y1

Y2 yono

Best regards,

Hello,

What you need to do is use UNION to merge the output from the two databases and if needed you can sort the out put into one large table intermixed:

Select * 
from 
(select table1.data_field as result1
from table1
UNION
select table2.data_field as result1
from table2) as data1
order by data1.result1

Or something roughly like that depending on the database you are using. UNION puts the results from one query together with the results from a second query provided they have the same names for the result data fields.

@ rch1231, thank you very much for your answer and it can work well.

@ rch1231, I have a query as follows:
select a.A, a.B from server1.dbo.table1 a
UNION
select b.A, b.B from server2.dbo.table1 b

but if the query is why I enter in the data environment on the current VB6 will create a data report, the fields that should appear in the data environment did not appear.
Can you help me @ rch1231

best regards,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.