1

I created the following console application with a reference to Microsoft.SqlServer.TransactSql.ScriptDom.dll:

Imports Microsoft.SqlServer.TransactSql.ScriptDom
Imports System.IO

Module Module1
    Sub Main()
        Dim sql = "SELECT * FROM Product OPTION(USE HINT('ENABLE_PARALLEL_PLAN_PREFERENCE'))"
        Dim parser As New TSql130Parser(False)
        Dim errors As Collections.Generic.IList(Of ParseError)
        Dim script As TSqlScript = parser.Parse(New StringReader(sql), errors)
        Console.WriteLine(errors(0).Message)
        Console.ReadKey()
    End Sub
End Module

Running this console application produces the following output:

Incorrect syntax near HINT.

But this SQL fragment is correctly parsed in Microsoft SQL Server Management Studio.

It seems therefore, that TSql130Parser does not work correctly. Do you know if there is a fix for this?

Alex
  • 419
  • 1
  • 5
  • 14

1 Answers1

1

You'll need to use the 14.0 version or later of Microsoft.SqlServer.TransactSql.ScriptDom.dll in order for the TSql130Parser to recognize the newer hint. The latest 14.0 version is 14.0.3811.1 as of this writing and is available as a NuGet package. There is also a 15.0 NuGet package version available, which supports SQL Server 2019 (currently in CTP) and the older TSqlParsers with the latest features.

Dan Guzman
  • 43,250
  • 3
  • 46
  • 71