|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 3:42 PM
Points: 52,
Visits: 228
|
|
Jack, I was able to come up with a way to crosstab the xml values. You could also use this to run a report I guess.
Make sure to change the ErrorTask and RunDate variables to values in your own load_errors table.
You might want to add this to your original post.
Thanks again
BEGIN -- Define Variables DECLARE @ListCol VARCHAR (1000) , @Query VARCHAR (2000) , @ErrorTask VARCHAR (100) , @RunDate VARCHAR (100)
SET @ListCol = '' SET @Query = '' SET @ErrorTask = 'DFT Load Credit Card' SET @RunDate = '2010-04-29 14:08:00'
-- Create dynamic column list given Error Task name SELECT @ListCol = (SELECT DISTINCT a.name + ',' FROM load_errors b cross apply error_details.nodes('//field') AS xmlrows(data) cross apply (SELECT xmlrows.data.value('./@name[1]','varchar(120)') AS field_name ) AS a(name) WHERE b.error_task = @ErrorTask FOR XML PATH('')) SET @ListCol = SUBSTRING(@ListCol, 1, LEN(@ListCol)-1)
-- Create dynamic query SET @Query = ' SELECT * FROM (SELECT t.load_error_id , t.package_run_date , t.error_task , t.error_step , t.error_code , t.error_desc , f.name , f.value FROM load_errors t --= blow out the rows from the xml column cross apply error_details.nodes(''//field'') as xmlrows(data) --= convert the nodes to two columns, field: name and value cross apply (select xmlrows.data.value(''./@name[1]'',''varchar(120)'') as field_name , xmlrows.data.value(''./@value[1]'',''varchar(120)'') as field_value ) as f(name,value) WHERE t.error_task = ''' + @ErrorTask + ''' AND t.package_run_date = ''' + @RunDate + ''' ) inner_table pivot (max(inner_table.value) for inner_table.name in (' + @ListCol + ') ) pvtfname '
-- Execute dynamic query EXEC(@QUERY) END
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Thursday, March 28, 2013 5:30 PM
Points: 39,
Visits: 363
|
|
Its a wonderful article. I learned a lot.
Tinku
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 1:01 PM
Points: 13,
Visits: 303
|
|
| This article fails to mention this technique will only log error messages generated within SSIS. Errors reported by the database engine (including SQL Server) will receive the generic "no status is available" error. In those cases, you cannot get the detailed error in the redirect that you would normally see if a package was set to fail on error. This is just another example of functionality included in most ETL tools, but lacking in SSIS.
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Friday, May 17, 2013 12:22 PM
Points: 10,571,
Visits: 11,871
|
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 1:01 PM
Points: 13,
Visits: 303
|
|
It seems like the issue is column level vs row level errors. The method call is showing predefined errors, but does not return the same message you see from the db engine. Here are two examples.
1. I have a unique index setup on a table. When we try to insert a dup, the error raised by the db engine is "Cannot insert duplicate key row in object 'TableName' with unique index 'Index_Name'. The duplicate key value is ...." The error we get in SSIS is "The data value violates integrity constraints. "
2. I have a trigger on a table that checks for overlapping dates, and raises a 16 level error with rollback. Instead of getting the error message generated in the trigger, we get "No status is available".
In searching for a method to return the error generated by the db, I find that it is not possible in SSIS. What makes it even more disappointing is that we know SSIS does have these errors at the package level because we get them in a package level OnError event handler if the package is setup to fail on error, but there is apparently no way to have this information at the row level during a redirect. I hope I am wrong about this, but at this point I have not found a way to do it in SSIS even though it would be a simple tsql script to accomplish the same thing.
|
|
|
|