cancel
Showing results for 
Search instead for 
Did you mean: 

displayed data with use 2 databases

marek_moravcik
Explorer
0 Kudos

Dear all.

I using 2 databases with UNION ALL using "Add command" like this:

SELECT "t_customer"."s_name", "t_customer"."d_sys_created"

FROM  "database1"."dbo"."t_customer" "t_customer"

UNION ALL

SELECT "t_customer"."s_name", "t_customer"."d_sys_created"

FROM  "database2"."dbo"."t_customer" "t_customer"

database1 was active (valid) until 30.april.2016 and

database2 is active from              1.may.2016

database2 is copy from database1

now please open attach file here question:

thanks very much

Accepted Solutions (1)

Accepted Solutions (1)

former_member205840
Active Contributor
0 Kudos

Hi Marek,

You can eliminate duplicates in crystal reports like :

option 1

Create a group on S_name, suppress details, and place all required fields in group footer.

option 2

Go in section expert--details-- suppress condition

If s_name=Previous(s_name) then true else false

Thanks,

Sastry

marek_moravcik
Explorer
0 Kudos

thanks Sastry very much

These are possible solutions

Answers (1)

Answers (1)

abhilash_kumar
Active Contributor
0 Kudos

Hi Marek,

Simply modify the query as:

SELECT "t_customer"."s_name", "t_customer"."d_sys_created"

FROM  "database1"."dbo"."t_customer" "t_customer"

UNION

SELECT "t_customer"."s_name", "t_customer"."d_sys_created"

FROM  "database2"."dbo"."t_customer" "t_customer"

-Abhilash

marek_moravcik
Explorer
0 Kudos

thanks Abhilash so easy and I did not know 

marek_moravcik
Explorer
0 Kudos

this one is ok, but I have else one question.

It is poossible write query with use UNION on  "Add command" like this?

SELECT            t_customer.name, t_user.firstname

FROM               t_customer LEFT OUTER JOIN

                         t_users ON t_customer.id = t_users.id

WHERE            t_user.firstname='mark'

GROUP BY       t_customer.name, t_user.firstname

UNION

SELECT       t_customer.name, t_user.firstname

FROM          t_customer LEFT OUTER JOIN

                         t_users ON t_customer.id = t_users.id

WHERE       t_user.firstname='mark'

GROUP BY  t_customer.name, t_user.firstname

Query writen over UNION is database1.dbo

Query writen under UNION is database2.dbo


It is possible this way to join two databases? I dont know where (how)  I write "database1"."dbo"

"database2"."dbo"


thank for help

abhilash_kumar
Active Contributor
0 Kudos

Hi Marek,

You cannot query Database 2 while logged into Database 1.

If you're reporting against an Oracle database, you can setup a db link on one of the database servers pointing to the other database.

Once a db link is setup, you can use the two databases together in a SQL query referring to the linked database using the @db_link_name.

More on db links here:

CREATE DATABASE LINK - Examples - Oracle Wiki - Oracle - Toad World

If this is not possible, you could try creating views on each database and then Join them in CR - depending on how many records are being returned, this approach could potentially slow down the report as such Joins are not processed by the database server.

-Abhilash

marek_moravcik
Explorer
0 Kudos

thanks for help Abhilash