How can do syntax check with osql and sqlcmd

  • SQL Analyzer can perform syntax check before actual SQL execution. Is there any way to do syntax check with osql and sqlmcd? thx

  • AFAIK, sqlcmd and osql do not have the ability to do syntax check.

    Pradeep Adiga
    Blog: sqldbadiaries.com
    Twitter: @pradeepadiga

  • Thx Adiga,

    Do you guy know is there any command line tool to parse SQL? thx.

  • @matthew.lau,

    I am not aware of any such tools. You can try this method in sqlcmd or osql.

    SET PARSEONLY ON

    go

    <YourQuery>

    SET PARSEONLY OFF

    go

    Pradeep Adiga
    Blog: sqldbadiaries.com
    Twitter: @pradeepadiga

  • thx Adiga, you are very helpful

  • matthew.lau (11/24/2010)


    SQL Analyzer can perform syntax check before actual SQL execution. Is there any way to do syntax check with osql and sqlmcd? thx

    I agree. They don't. I guess I don't understand why you wouldn't develop such things in SSMS, though. It's a whole lot easier to write code in SSMS than it is in NotePad (for example).

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

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

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