Reputation: 442
When parsing in a SQL query like:
SELECT g.A, g.B, g.C FROM dbo.Goat g inner join dbo.Badger b on g.A=b.A
and iterating through TSqlParserToken there is a Property called TokenType. I get the following:
SELECT Select
WhiteSpace
g Identifier
. Dot
A Identifier
, Comma
WhiteSpace
g Identifier
. Dot
B Identifier
, Comma
WhiteSpace
g Identifier
. Dot
C Identifier
WhiteSpace
FROM From
WhiteSpace
dbo Identifier
. Dot
Goat Identifier
WhiteSpace
g Identifier
WhiteSpace
inner Inner
WhiteSpace
join Join
WhiteSpace
dbo Identifier
. Dot
Badger Identifier
WhiteSpace
b Identifier
WhiteSpace
on On
WhiteSpace
g Identifier
. Dot
A Identifier
= EqualsSign
b Identifier
. Dot
A Identifier
I understand that in order for the parser to return these values it need to have an awareness of the underlying schema. Is it possible for me to feed the parser with the underlying objects so it can return a more aware set of tokens?
The TSqlTokenType enum also has values such as ‘Table’,’Schema’, ‘View’ so I’m sure this must be possible. It’s just the documentation is scarce. Dan
Upvotes: 2
Views: 1772