我使用对 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
运行此控制台应用程序会产生以下输出:
Incorrect syntax near HINT.
但此 SQL 片段已在 Microsoft SQL Server Management Studio 中正确解析。
因此,TSql130Parser 似乎无法正常工作。您知道是否有解决此问题的方法吗?