Closed allnamesaretaken2343 closed 9 months ago
Otherwise, errors seem unrelated to actual error...
SELEC CAST('blah blah' As int) Message = "Incorrect syntax near 'blah blah'."
SELECT CAS('blah blah' As int) Message = "Incorrect syntax near As."
Is there a better library out there to parse SQL?
Yes SELECT CAST('blah blah' As int)
is valid at parse time.
It only throws an error at execution time.
What about the bad error messages?
SELECT CAS('blah blah' As int) Message = "Incorrect syntax near As." More appropriate would be, 'CAS' is not a recognized built-in function name.
I made my own solution, as this library does not produce correct or relevant error messages.
@allnamesaretaken2343, can you please help us understand your ultimate goal?
As a parser, it is not in the scope of SqlScriptDom to return errors like Conversion failed when converting the varchar value 'blah blah' to data type int
when you execute SELECT CAST('blah blah' As int)
. As @clement911 already mentioned, this statement is 100% valid from a parser perspective. The Error 245 (conversion failed...)
that's returned, is part of the SQL execution engine and is out of scope for a parser. This specific example is not a bug at least as far as SqlScriptDom's intended scope is concerned.
Just testing this library, and it just, does not work?
Testing multiple bad SQL... And even the simplest variations go through?
SELECT CAST('blah blah' As int)
This is valid SQL according to Microsoft.SqlServer.TransactSql.ScriptDom ?!
Or am I doing it wrong?