USE [Synergy] GO /****** Object: Trigger [dbo].[ConsNobTrRaiseErrorProcessLog] Script Date: 27-11-2019 21:27:23 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TRIGGER [dbo].[ConsNobTrRaiseErrorProcessLog] ON [dbo].[BacoProcessLog] AFTER INSERT AS BEGIN SET NOCOUNT ON; DECLARE @CommandLine as NVARCHAR(500) DECLARE @Message as NVARCHAR(2048) SELECT @CommandLine = inserted.CommandLine, @Message = LEFT(CONCAT(N'Background process ',inserted.ProcessName,N' reported the following error: ',inserted.LogText,N' Additional information: Background process: ',inserted.ProcessName,N' Command Line: ',inserted.CommandLine,N' Server: ',inserted.Server,N' Database: ',DB_NAME(),N' (',@@SERVERNAME,N') Table: dbo.BacoProcessLog Log Date: ',convert(nvarchar(20),inserted.LogDate,121),N' Log ID: ',cast(inserted.LogID as nvarchar(50)),N' Application: '+APP_NAME(),N' SPID: '+cast(@@SPID as nvarchar(50)),N' System user: '+SYSTEM_USER ),2048) FROM inserted WHERE inserted.LogType = 3 and inserted.LogText is not null IF @CommandLine is not null --AND (@CommandLine like '%AR0030%' or @CommandLine like '%FACT03%') BEGIN RAISERROR (@Message,16,1) WITH LOG; END END GO ALTER TABLE [dbo].[BacoProcessLog] ENABLE TRIGGER [ConsNobTrRaiseErrorProcessLog] GO
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter