Modify the log information of the stored procedure insert custom ssis SQL Server

Source: Internet
Author: User
Tags ssis
The log information of the package does not contain the logs when the package is successfully executed. Sometimes we only care about whether the package is successfully executed or fails.

Although the SQL Server SSIS log provider does not record successful packet execution information by default, you can modify the stored procedure it calls to record a successful message.

1. Right-click the blank space in the control flow of the package and choose j logging.

2. Add an SQL Server SSIS log Provider Program and configure the connection string in the Wizard.

3. Select the Onerror event in the details.

When the package is run for the first time, it is installed in the database to create a table and the stored procedure name is: sysdtslog90, sp_dts_addlogentry.

Next, we can modify the stored procedure to implement custom logging!

The following describes a stored procedure for successfully added information for your reference:

Alter procedure [dbo]. [sp_dts_addlogentry]
@ Event sysname, @ computer nvarchar (128), @ operator nvarchar (128 ),
@ Source nvarchar (1024), @ sourceid uniqueidentifier,
@ Executionid uniqueidentifier, @ starttime datetime,
@ Endtime datetime, @ datacode int, @ databytes image,
@ Message nvarchar (2048)

Insert into sysdtslog90
(Event, computer, operator,
Source, sourceid, executionid,
Starttime, endtime, datacode,
Databytes, message) VALUES
(@ Event, @ computer, @ operator,
@ Source, @ sourceid, @ executionid,
@ Starttime, @ endtime, @ datacode,
@ Databytes, @ message)
-- When the package execution ends, search. If the OnError event does not exist, it indicates that the package has been successfully executed.
If @ event = 'packageend'
Begin
If not exists (select * from sysdtslog90 where executionid = @ executionid and [event] = 'onerror ')
Begin
Insert into sysdtslog90
(Event, computer, operator,
Source, sourceid, executionid,
Starttime, endtime, datacode,
Databytes, message) VALUES
('Successed ', @ computer, @ operator,
@ Source, @ sourceid, @ executionid,
@ Starttime, @ endtime, @ datacode,
@ Databytes, 'the package is processed successfully! ')

End
End
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.