USE [tempdb]
IF OBJECT_ID (N'#TempTable') IS NULL
BEGIN
BEGIN TRY
CREATE TABLE #TempTable
(
AuditUser varchar(36) not null default '',
AuditIP varchar(39) not null default '',
AuditNotes varchar(4000) not null default '',
AuditClientUTC datetime not null default getutcdate(),
)
INSERT INTO #TempTable(AuditUser,AuditIP,AuditNotes,AuditClientUTC)
values('','','',getutcdate())
END TRY
BEGIN CATCH
SELECT ERROR_NUMBER() AS ErrorNumber;
END CATCH
END
USE [microCMMSTestNew]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TRIGGER [dbo].[trcmmsdeleteOperation]
on [dbo].[Person]
after delete AS
begin
declare @AuditServerUTC [datetime]
INSERT INTO [dbo].[PersonAudit]
([fKeyBase]
,[AuditServerUTC]
,[AuditClientUTC]
,[AuditUser]
,[AuditIP]
,[AuditNotes]
,[FirstName]
,[LastName]
,[Status])
select d.GUID
,d.AuditServerUTC
,d.AuditClientUTC
,d.AuditUser
,d.AuditIP
,d.AuditNotes
,d.FirstName
,d.LastName
,d.Status
FROM Deleted d
end
In the above SQl statements when I execute it's working but when this SQL script close the editor of SSMS only trigger is viewed but not before sql statements.