Is there a way (or existing library, not necessarily built into .NET) in C# that performs simple SQL string validation?
Scenario: Building update statement to reduce load on SQL load vs. individual statements. In case the string build does something "odd", like ending with a comma for instance, I'd like to be able to validate that the string is correct.
If you want to validate the SQL using SQL Server, you can do so by adding
SET PARSEONLY ON
before your script, and then
SET PARSEONLY OFF
after your script.
If you need to avoid going to the database, then maybe you can use the assemblies that Microsoft Visual Studio Team System 2008 Database Edition GDR includes (they have code that handles SQL parsing and script generation). If you don't have the database edition or team suite, you can download the trial version to get the assemblies.
Here is a link I found where someone is using these assemblies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With