Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
francofiorillo
Partner - Creator
Partner - Creator

know the name of the db

know the name of the db
hello

I would like to kindly help.

I need to load and concatenate together the same table, we call to exemplify INVOICES, several data base.

for the individual lines of coming conoscerela INVOICES I thought of adding a field in the table the name of the DB.

I do not know if you know the name of the DB and how do you add in an additional field in the load the contents of this possible variable containing the name of the DB.

Thank you in advance for any feedback

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

Maybe this?

[Invoices]:
LOAD *
,'Database1' as Database
;
SQL SELECT
Invoice
,Amount
FROM Database1
;
CONCATENATE ([Invoices])
LOAD *
,'Database2' as Database
;
SQL SELECT
Invoice
,Amount
FROM Database2
;

Or maybe this if you're loading exactly the same fields from each database:

FOR EACH vDatabase IN 'Database1','Database2'
    [Invoices]:
    LOAD *
    ,$(vDatabase) as Database
    ;
    SQL SELECT
     Invoice
    ,Amount
    FROM $(vDatabase)
    ;
NEXT

View solution in original post

2 Replies
johnw
Champion III
Champion III

Maybe this?

[Invoices]:
LOAD *
,'Database1' as Database
;
SQL SELECT
Invoice
,Amount
FROM Database1
;
CONCATENATE ([Invoices])
LOAD *
,'Database2' as Database
;
SQL SELECT
Invoice
,Amount
FROM Database2
;

Or maybe this if you're loading exactly the same fields from each database:

FOR EACH vDatabase IN 'Database1','Database2'
    [Invoices]:
    LOAD *
    ,$(vDatabase) as Database
    ;
    SQL SELECT
     Invoice
    ,Amount
    FROM $(vDatabase)
    ;
NEXT

francofiorillo
Partner - Creator
Partner - Creator
Author

perfect. was what I wanted. it works. thank you very much.