Running T-SQL script

  • I must synchronise more databases.

    I prepare script with new or changed objects.

    In VB6 I use DMO ExecuteImmediate and work fine, but not return errors or PRINT statements, so I try ExecuteWithResultsAndMessages, they return errors but doesn't work. On  T-SQL GO, SET, ... statement returning Error (Incorrect syntax near GO).

    Where is differents between ExecuteImmediate and ExecuteWithResultsAndMessages, so I prepare well script.

    Is any other metod exists to running T-SQL script from VB. 

    Any suggestion ...

    Thanks

  • You get an error because "GO" is not a T-SQL keyword, it's a batch separator; normally it should be processed by the client tools (not by the server). You could parse the script (searching for lines containing "GO"-s) and execute each part of the script with a separate call to ExecuteWithResultsAndMessages. Or you can call the OSQL command-line utility (if the SQL Server Client Tools are installed).

    Razvan

Viewing 2 posts - 1 through 1 (of 1 total)

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