简体   繁体   中英

SQL JOIN AS400 from table #temp

I want to make a dynamic join between sql and as400, of this type:

SELECT * FROM OPENQUERY(AS400_link,'SELECT                                  
        AS400.CAMPO1
        ,AS400.CAMPO2
        ,AS400.CAMPO3
        ,AS400.CAMPO4                                           
    FROM AS400_FILE AS AS400
    INNERT JOIN #TAB_TEMP AS TEMP ON
        TEMP.CAMPO1 = AS400.CAMPO1
    ')

DROP TABLE #TAB_TEMP

if I run it:

OLE DB provider "IBMDASQL" for linked server "AS400_link" returned message "SQL0113: Nome #TAB_TEMP non consentito. Causa . . . : #TAB_TEMP...

some solution? Thank you

I think what you're looking for is more like

SELECT * FROM OPENQUERY(AS400_link,'SELECT 
        AS400.CAMPO1
        ,AS400.CAMPO2
        ,AS400.CAMPO3
        ,AS400.CAMPO4                                           
    FROM AS400_FILE') AS AS400
    INNER JOIN #TAB_TEMP AS TEMP ON
        TEMP.CAMPO1 = AS400.CAMPO1

Don't expect it to perform well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM