SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SQL Parser!


SQL Parser!

Author
Message
TrucPham
TrucPham
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 1
I need a SQL parser (with source code) where it takes as input an SQL statement, and parses it and outputs columns, tables, Type of operation(Select,Insert,Delete...).

Someone knows somthing like this in .NET (prefered in VB.NET)

Regards
MVDBA
MVDBA
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3487 Visits: 860
what standard of SQL ? ANSI? T-SQL?

what type of output do you want? text file?

why ot just use the isqlw.exe feature of sql server and the -i -o parameters??

MVDBA
TrucPham
TrucPham
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 1

Thank you for your consideration!

In fact, I would like to validate a SQL statement is inputed by user. For example, if users input a SQL statement from a textbox:" Select product_name, product_type from Products inner join ProductTypes on Products.product_typeid=ProductTypes.product_typeid where Products.product_typeid='1' ", I will validate this statement, so that I parse fields returned (product_name, product_type) I want in my program in VB.NET.

Pls help me!

Thanks a lot


Joe Clifford
Joe Clifford
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1111 Visits: 619

Uh oh! Please google "sql injection" before you get to far along with your project, the type of application you are proposing is incredibly risky/dangerous.





MVDBA
MVDBA
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3487 Visits: 860
all you are doing here is replicating what the SQL server is doing....

if you are using ADO.net then you can send the query and return a recordset.

the ado recordset object can then be queried to find with fields, qty of data etc are returned.

MVDBA
Frank Kalis
Frank Kalis
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10665 Visits: 289
Like Mike already said, you're trying to reinvent the wheel!

If I were you, I wouldn't waste my time with such a thing.

The other important consideration is also already mentioned: SQL Injection

Read this and decide if that's still the way for you to go. Maybe you decide to go down stored procedures road to have better control.

--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/
Frank Kalis
Frank Kalis
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10665 Visits: 289
Btw, there is SET PARSEONLY { ON | OFF }. Never used it myself, but might be worth having a look at in BOL.

--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/
TrucPham
TrucPham
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 1

Hello All!

In fact, I would like to thank, thank all of you. I changed the requirement and performed by another way. Thank you any ways.

Regards


Steve Feichtl
Steve Feichtl
SSC Journeyman
SSC Journeyman (92 reputation)SSC Journeyman (92 reputation)SSC Journeyman (92 reputation)SSC Journeyman (92 reputation)SSC Journeyman (92 reputation)SSC Journeyman (92 reputation)SSC Journeyman (92 reputation)SSC Journeyman (92 reputation)

Group: General Forum Members
Points: 92 Visits: 84

I too had a developer ask me about validating sql data from an app he wrote that allowed users to input T-SQL statements and the SET PARSEONLY worked out great.

Thanks again for your posting of that info.

Steve




Kindest Regards,

Steve Feichtl
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search