Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Sa20
Contributor II
Contributor II

Connect multiple databases sql

Please how can i connect multiple databases sql to analyze it as a single database in qlikView ?

5 Solutions

Accepted Solutions
shiveshsingh
Master
Master

You can create multiple connection strings and import data in qlikview.

After that, you can create single model as per your requirement.

View solution in original post

rubenmarin

Hi, you can store connection string in txt, and use a for each bucle to connect to each one to retrieve data, ie, assuming that all databases have the same tables:
for each table in 'table1','table2','table3' //fill with table names
for each connection in 'Connection1','Connection2','Connection3' //fill with txt names of connection strings
$(Include=path_to_connections\$(connection).txt); //this loads the connection
// Retrieve data from all connections
[$(table)]:
LOAD '$(connection)' as connection,
*
from [$(table)];
next
// store joined data into a qvd, this qvd will be readed by the app to load the data
Store [$(table)] into [Path_to _qvds_folder\$(table).qvd];
Drop [$(table)];
next

View solution in original post

jonathandienst
Partner - Champion III
Partner - Champion III

Follow this pattern:

  1. Connection for first database
  2. Load whatever data required from first database
  3. Open connection for next database (this will implicitly disconnect the first)
  4. Load whatever data required from second database (and concatenate or join to the earlier tables as required)
  5. Open connection to third database
  6. Etc Etc

The data from all the sources will be loaded into a single QVW file for analysis.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

Sa20
Contributor II
Contributor II
Author

But databases do not have the same tables

View solution in original post

rubenmarin

You can create different variables to store table names:
SET vTablesConnection1 = 'Table1_Conn1', 'Table2_Conn1';
SET vTablesConnection2 = 'Table1_Conn2', 'Table2_Conn2';

for numberOfConnection=1 to 2
for each table in $(vTablesConnection$(numberOfConnection))
...
Next

View solution in original post

5 Replies
shiveshsingh
Master
Master

You can create multiple connection strings and import data in qlikview.

After that, you can create single model as per your requirement.

rubenmarin

Hi, you can store connection string in txt, and use a for each bucle to connect to each one to retrieve data, ie, assuming that all databases have the same tables:
for each table in 'table1','table2','table3' //fill with table names
for each connection in 'Connection1','Connection2','Connection3' //fill with txt names of connection strings
$(Include=path_to_connections\$(connection).txt); //this loads the connection
// Retrieve data from all connections
[$(table)]:
LOAD '$(connection)' as connection,
*
from [$(table)];
next
// store joined data into a qvd, this qvd will be readed by the app to load the data
Store [$(table)] into [Path_to _qvds_folder\$(table).qvd];
Drop [$(table)];
next

jonathandienst
Partner - Champion III
Partner - Champion III

Follow this pattern:

  1. Connection for first database
  2. Load whatever data required from first database
  3. Open connection for next database (this will implicitly disconnect the first)
  4. Load whatever data required from second database (and concatenate or join to the earlier tables as required)
  5. Open connection to third database
  6. Etc Etc

The data from all the sources will be loaded into a single QVW file for analysis.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Sa20
Contributor II
Contributor II
Author

But databases do not have the same tables

rubenmarin

You can create different variables to store table names:
SET vTablesConnection1 = 'Table1_Conn1', 'Table2_Conn1';
SET vTablesConnection2 = 'Table1_Conn2', 'Table2_Conn2';

for numberOfConnection=1 to 2
for each table in $(vTablesConnection$(numberOfConnection))
...
Next