Step 1
Create a variable global variable as a string type leaving the value empty. In this instance, it’s called mysqlwarnings.

Step 2
Put your command and arguments appropriately in the execute process task properties Once done point to the variable created in Step 1 (mysqlwarnings). For those concerned about the mysql portion I’m generating a warning by inserting a datetime value into a date field. I run the “Show warnings” to be captured to the output variable
insert into datetest values('2008-01-01 11:00:00');show warnings;"

Once the variable has been given the output the last thing to do is write it to a text file using a script task. The code should look like this. Remember to set imports system.io to get this to work.
Public Sub Main()
Dim sw As New StreamWriter("c:\warningsout.txt")
sw.Write(Dts.Variables("mysqlwarnings").Value.ToString())
sw.Close
Dts.TaskResult = Dts.Results.Success
End Sub
See my previous blog where I show how to fail a package based on data in a file.
No comments:
Post a Comment