未找到语法错​​误插入临时表

时间:2017-09-21 22:03:13

标签: sql sql-server

我有一个查询在临时表上插入数据,如下所示:

INSERT INTO ##TGJAE
    SELECT
        TT.RECID, TT.TRANSDATE,
        TT.DATAAREAID, TT.SOURCERECID,
        TT.SOURCECURRENCYCODE, TT.TAXAMOUNT,
        TT.TAXBASEAMOUNT, TT.TAXBASEAMOUNTCUR,
        TT.TAXAMOUNTCUR, TT.TAXORIGIN, TT.VOUCHER,
        TT.TAXITEMGROUP, TT.TAXCODE, 
        TT.SOURCEBASEAMOUNTCUR, TT.SOURCETAXAMOUNTCUR,
        TTGJAERIVA.TAXTRANSRELATIONSHIP,
        TTGJAERIVA.GENERALJOURNALACCOUNTENTRY,
        TTGJAERIVA.LEDGERDIMENSION,
        GJAERIVA.TEXT, GJAERIVA.LEDGERDIMENSION,
        GJAERIVA.POSTINGTYPE
    FROM 
        TAXTRANS TT 
    INNER MERGE JOIN 
        TAXTRANSGENERALJOURNALACCOUNTENTRY TTGJAERIVA ON TTGJAERIVA.TAXTRANS = TT.RECID
    INNER MERGE JOIN 
        GENERALJOURNALACCOUNTENTRY GJAERIVA ON TTGJAERIVA.GENERALJOURNALACCOUNTENTRY = GJAERIVA.RECID 
                                            AND GJAERIVA.POSTINGTYPE IN (14, 236, 71, 41) 
                                            AND TT.TRANSDATE <= '2017-06-30'
    WHERE 
        (TT.TAXORIGIN <> 11 AND 
         TT.TRANSDATE BETWEEN '2016-06-30'  AND '2017-06-30') 
        OR 
        (TT.TAXORIGIN = 11 AND 
         TT.TRANSDATE BETWEEN '2017-06-01' AND '2017-06-30' )) AS T 

由于某些原因,在查询结束时会抛出错误:

  

')'

附近的语法不正确

enter image description here

我检查它是永恒的,但我没有错。有人可以看错吗?此致

1 个答案:

答案 0 :(得分:2)

没有开括号来匹配突出显示的关闭的paren。