We have an updater application which executes SQL scripts of over 30,000 lines of code on a SQL Server database. In this script is a large number of GO
statements. The ADO components which I'm used to using do not support the GO
statement. We've always used the OSQL
command-line when updating the server, which is tricky to catch the problems (outputs a text file which we then have to parse to look for errors and results). It would be much more ideal if something in Delphi was able to find those GO
statements and execute each block at a time.
I do understand that the GO
statement is specific to MS tools which are able to execute them. Again the script is over 30,000 lines of code, with at least 500 GO
statements. We use the same script in SQL Management Studio and OSQL for the updater. But OSQL just isn't giving us the results we need - it's a sloppy way of executing such a script.
Is there any existing SQL Server compatible tool for Delphi which recognizes GO
statements? I'm not talking necessarily about a parser (although I'm sure parsing would be involved), I'm talking about a ready-made utility to execute SQL Scripts which contain GO
statements and return the results of each script block.
For example, one block might create a table, and then GO
, and then create a stored procedure for that table and another GO
. The code is so complex that implementing it in the code like this question is quite out of the question.
UPDATE
I have successfully written a small bit of working code that does this, however it does not take into consideration a GO
statement within a comment block.
I'm not asking anything further in this question, just thought I'd share where I am with this.