How to do an INNER JOIN in SSIS Excel Source component

前端 未结 2 1278
闹比i
闹比i 2021-01-27 18:07
SELECT   [Sheet1$].ID,
CLng([Sheet1$].RecordID) AS RecordID, 
[Sheet1$].col1, 
[Sheet1$].col2, 
[Sheet1$].col3, 
[Sheet1$].col4, 
[Sheet1$].col5,
[Sheet2$].Name
FROM             


        
2条回答
  •  温柔的废话
    2021-01-27 18:50

    Ok, i was doing it the wrong way. Microsoft access database engine used by the SSIS Excel Source component handles joins differently than SQL Server.

    Apparently, you need to have n - 2 left parentheses after the from clause and one right parenthesis before the start of each new join clause except for the first, where n is the number of tables being joined together.

    The reason is that Access's join syntax supports joining only two tables at a time, so if you need to join more than two you need to enclose the extra ones in parentheses.

    Quoted from Access-SQL: Inner Join with multiple tables

    And confirmed at http://office.microsoft.com/en-001/access-help/inner-join-operation-HA001231487.aspx

    So the below query now works

    SELECT   [Sheet1$].ID,
    CLng([Shee1$].RecordID) AS RecordID, 
    [Sheet1$].col1, 
    [Sheet1$].col2, 
    [Sheet1$].col3, 
    [Sheet1$].col4, 
    [Sheet1$].col5,
    [Sheet2$].Name
    FROM      (([Sheet1$])
    INNER JOIN [Sheet2$] ON [Sheet1$].RecordID = [Sheet2$].RecordID)
    INNER JOIN [Sheet3$] ON [Sheet1$].RecordID = [Sheet3$].RecordID
    

提交回复
热议问题