taozhi8833998 / node-sql-parser

Parse simple SQL statements into an abstract syntax tree (AST) with the visited tableList and convert it back to SQL
https://taozhi8833998.github.io/node-sql-parser/
Apache License 2.0
750 stars 172 forks source link

TransactSQL - SELECT > INTO #temp_table not supported #1978

Closed wabreu-xtillion closed 1 week ago

wabreu-xtillion commented 1 week ago

Describe the bug I'm trying to convert to AST a query that creates temporary tables using SELECT * INTO #temp_table FROM table. This is not supported and I have to remove the INTO #temp_table for query to parse.

Database Engine TransactSQL

To Reproduce SELECT SSEF.ClientTypeId, COACH.EnrollmentId, COACH.InteractionId, COACH.InteractionCloseDate, COACH.InteractionCloseDateTs, COACH.InteractionCloseModality, COACH.InteractionPurpose, COACH.CoachingSessionSequence, COACH.IsCoachingSessionYN, COACH.IsAdminSupportYN, COACH.EVENT_CK, COACH.IS_BILLABLE_EVENT INTO #tem_table FROM [RptQFL].[vw_ClosedCoachInteractions] AS COACH WITH (NOLOCK) INNER JOIN [RptQFL].[vw_StateStandardExtractFields] AS SSEF WITH (NOLOCK) ON SSEF.EnrollmentId = COACH.EnrollmentId WHERE COACH.IS_BILLABLE_EVENT = 1 AND SSEF.IsEnrollmentValid = 1 AND COACH.InteractionCloseDate BETWEEN @BeginDt AND @EndDt;

Expected behavior I expected the parser to return the AST for this query.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Error in the console:

{
    "message": "Expected [A-Za-z0-9_\\-@$] but \" \" found.",
    "expected": [
        {
            "type": "class",
            "parts": [
                [
                    "A",
                    "Z"
                ],
                [
                    "a",
                    "z"
                ],
                [
                    "0",
                    "9"
                ],
                "_",
                "-",
                "@",
                "$"
            ],
            "inverted": false,
            "ignoreCase": false
        }
    ],
    "found": " ",
    "location": {
        "start": {
            "offset": 358,
            "line": 14,
            "column": 5
        },
        "end": {
            "offset": 359,
            "line": 14,
            "column": 6
        }
    },
    "name": "SyntaxError"
}