Title: Mod to SqlTask

All,

Sean and I submitted these changes a few weeks ago, but got no response. Is this the proper forum to submit enhancements?

We have since updated the SqlTask and supporting classes further. In addition to fixing some logic when executing SQL Server scripts from a file, we have fixed a bug to that caused the task to attempt to execute an empty SQL statement. Additionally, we incorporate the code added by Tomas to ExpandProperties. 

The existing task caused problems when you have a script like this:

declare @userName varchar(30)
SELECT @userName = 'sa'
EXEC sp_who @userName
GO

declare @userName varchar(30)
SELECT @userName = 'sa'
EXEC sp_who @userName
GO

We could only get it to execute each line as a separate batch, which would give us errors stating that @userName was not defined, OR as a single batch causing errors that @userName was defined more than once.

So we enhance the logic to properly run scripts when line="true" and batch="false". The SqlStatementList class now reads everything until it reaches the delimiter and places everything into a single batch. The formatting and comments from the scripts are not stripped out in this mode.

Tasks - primarily added code to make verbose="true" actually do something

<<SqlTask.ZIP>>
Utils - exposed the Connection object in SqlHelper so informational messages and warnings could be consumed in the SqlTask class. Added logic to SqlStatementList to handle multi-line sql scripts that must be processed as a single batch.

<<SqlStatementList.ZIP>> <<SqlHelper.ZIP>>

Tests - added a couple tests for the "Line" style

<<SqlStatementListTests.ZIP>>

Regards,
Jay Turpin and Sean Demartino


Attachment: SqlTask.ZIP
Description: SqlTask.ZIP

Attachment: SqlStatementList.ZIP
Description: SqlStatementList.ZIP

Attachment: SqlHelper.ZIP
Description: SqlHelper.ZIP

Attachment: SqlStatementListTests.ZIP
Description: SqlStatementListTests.ZIP

Reply via email to