SSIS Logging Example : Logging Detailed Information and
Errors
20140610
Created By : JRD
References
Example based on:
Misc References:
Multiple Errors (advanced)
SSIS Utilities on CodePlex for ssis lots of cool tools:
SSIS
Logging Example Project
Pre-Requisites: Step 1-3
AdventureWorks2012, and Adventureworks2012 DB
Create the table and sproc in the zip qry_LogEvent and ServiceEventLog, word doc in zip has screen shots
Create the table and sproc in the zip qry_LogEvent and ServiceEventLog, word doc in zip has screen shots
See [local], has these db’s
Login as : Sql Authentication
logginguser
pass@word1
package
password: Jas0n
- The Logging
Stored Procedure: (DONE) adventureworks2012.dbo.qry_LogEvent
-- log an INFO message
execute adventureworks2012.dbo.qry_LogEvent @ServiceID=10,
@Message='Start from GetSAPMasterData()', @EventID=100
-- log an ERROR message
execute adventureworks2012.dbo.qry_LogEvent @ServiceID=10,
@Message='Start from GetSAPMasterData()', @EventID=100
execute adventureworks2012.dbo.qry_LogEvent 'error
happened!', 9, 103, 'ERROR', 'SqlException'
- The logging
Table (DONE) adventureworks2012..[ServiceEventLog]
This is where messages are
logged:
a. select * from adventureworks2012..[ServiceEventLog] where Serviceid = 10
- Your SSIS
pck’s uses Service ID = 10 this is the ID used in Logging below:
SSIS: Step 3-6
Open the project , test the connection, all the below steps
are already done in the example project but are documented for assistance.
- *** Configure SSIS
Package for Logging! Lets do the first task
- Add Pre/Post Event Handler if u so
desire
- Add OnError Event Handler for the
Task:
i. Pass
the ErrorDescription into the SQL task as follows,
1.
Open the “Error Custom Logging” SQL task here
to see:
ii.
- Execute
- Check Results,
see how your Machine Name is listed,
schema of table is modeled after the “Windows Event Log” schema, If your
machine name is not listed then an error occurred logging to table.
select * from adventureworks2012..[ServiceEventLog] where Serviceid = 10
- Test error Logging!
- Create an ERROR
to test:
SELECT FirstName,
MiddleName,
cast(1/0 as nvarchar) LastName
FROM Person.Person
- Execute package
- Check errors, take note we got the Full Error
message!!!
- Set sql back to
way it was
SELECT FirstName,
MiddleName,
LastName
FROM Person.Person
- If you don’t want error to interrupt flow, : (same as try catch{}
with no throw), this would allow ur package to continue execution.
No comments:
Post a Comment