Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to parse SQL files using C#?

Can anyone please help me?

I am having bunch of .sql files. I want to parse (validate) those files before executing them on server.

I have many online sites which parse the code. But I want to parse the code using C#.

So please can you guide. If there is any tool, dll I need to use.

I just want to parse the file and not execute it

like image 659
Sunil Agarwal Avatar asked Jun 01 '10 18:06

Sunil Agarwal


2 Answers

A way to do it is to execute it on the server, except with SET PARSEONLY ON (so that it's parsed but not executed): I think that's how the MS Query Analyzer does it.

like image 140
ChrisW Avatar answered Sep 18 '22 04:09

ChrisW


You can have procedure which can get the query as input and
in SQL Server side you can have a SET PARSEONLY ON statement and then "run" the query. The query won't actually run, but any errors will be reported.

like image 24
Incognito Avatar answered Sep 19 '22 04:09

Incognito