Which dll is used for parsing query in sql server?

  • I wnat to create a small application like querry anlyzer in which i want to need parse the query. so any one know please tell me wich dll is used for parse the query i used that dll in my project.

  • [font="Verdana"]Vipul, as per my knowledge we can not directly use such DLLs. Even I don't know how SQL Server parses the query and SQL Server has such DLL as well. So what I will suggest here is to do it on your own. I mean you need to parse the query and needs to check whether it is correct, right? Then just do one thing, at the end of your query just add one more criteria, i.e. ... And 1 = 2, and execute it. What it will do is, it will execute your query and will return nothing.

    May be this is not the perfect solution. But try and let us know. Meanwhile you will get better soltution from exeperts on this.

    Mahesh[/font]

    MH-09-AM-8694

  • vipul (4/19/2008)


    I wnat to create a small application like querry anlyzer in which i want to need parse the query. so any one know please tell me wich dll is used for parse the query i used that dll in my project.

    If you want to check if a statement is syntactically correct, just use

    SET PARSEONLY ON

    and SET PARSEONLY OFF

    before and after the statement, and execute it. SQL Server will not execute the statement, but will give you back all the errors.

    If you want to build an abstract syntax tree for T-SQL statements, then you will need to write your own parser.

    Regards,

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

  • [font="Verdana"]

    Andras Belokosztolszki (4/21/2008)


    vipul (4/19/2008)


    I wnat to create a small application like querry anlyzer in which i want to need parse the query. so any one know please tell me wich dll is used for parse the query i used that dll in my project.

    If you want to check if a statement is syntactically correct, just use

    SET PARSEONLY ON

    and SET PARSEONLY OFF

    before and after the statement, and execute it. SQL Server will not execute the statement, but will give you back all the errors.

    If you want to build an abstract syntax tree for T-SQL statements, then you will need to write your own parser.

    Regards,

    Andras

    Thanks Andras, even this is new for me. By the way, If he will use SQL Server to check syntax, then how to handle the situation with and without Error? How to return the error message to the application? Or even with @@ERROR?

    Thanks in advance,

    Mahesh[/font]

    MH-09-AM-8694

  • Mahesh Bote (4/21/2008)


    [font="Verdana"]

    Thanks Andras, even this is new for me. By the way, If he will use SQL Server to check syntax, then how to handle the situation with and without Error? How to return the error message to the application? Or even with @@ERROR?

    Thanks in advance,

    Mahesh[/font]

    You will not get back any resultsets if you specify PARSEONLY. What you can do in your applications is to capture the messages from SQL Server. In case of a .Net application, the SqlConnection class has an InfoMessage event to which you can subscribe.

    Regards,

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply