Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
david_ze
Partner - Contributor III
Partner - Contributor III

how to load multiple SQL DB ?

Hi, I have an issue in loading multiple SQL DB.

First, I'm loading the list of the companies:

SQL SELECT COMP_NAME, LANG
FROM system.dbo.ENVIRONMENT;

The table looks like this:

Company_1, eng

Company_2, spn

Company_3, ger

now I would like to load each company's data which is located in the company's Database (the name of the database is the content of the COMP_NAME i.e, Company_1, Company2_Comapny_3 etc  so the name of the Database shoud be   Company_1.dbo.'table name').

I will appreciate your help on how to create a loop which will run on the SQL SELECT and will load all the companies data.

Thanks in advanced.

David

3 Replies
Not applicable

I havent had to load from 2 sql's but what about creating a qvd load from one of them ?

Not applicable

Hello David,

You can use 2 connects in the same QVD file.

I already did this:

odbc connect to BASE1

SELECT * FROM TB_REGISTER

ODBC CONNECT TO BASE2

SELECT * FROM TB_REGISTER2

i have helped

Regards,

Ricardo Nepomuceno

danielrozental
Master II
Master II

Try something like this.

SQL SELECT COMP_NAME, LANG

FROM system.dbo.ENVIRONMENT;

for i = 1 to fieldvaluecount('COMP_NAME')

          Let vDatabase = fieldvalue('COMP_NAME',i);

 

          SQL SELECT *

          FROM $(vDatabase).dbo.TABLE1;

next