Мы начали с базы данных и таблиц SQL Server 2005. [UPDATE, INSERT и DELETE] в этом случае мы использовали триггер (ы) UPDATE для вставки строк в таблицы аудита при изменении таблицы данных приложения (VB6). Мы переместили таблицы аудита в SQL Server 2008. Единственное изменение в выражении (ях) триггера (в SQL Server 2005) мы изменили оригинал ([FHA-4]) на новый (SQL Server 2008 [FHA-DMZ CL1SQL]) имя сервера.
Когда триггер активирован, песочные часы остаются включенными до тех пор, пока не появится сообщение о превышении времени ожидания sql и приложение не прекратит работу. При проверке таблиц аудита ничего нового не добавляется, поэтому вставка не работает.
Вот фактический оператор триггера для таблицы:
USE [BCC_DHMH]
GO
/****** Object: Trigger [dbo].[TriggerAddressUpdate] Script Date: 04/07/2010 09:47:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--Logic to save to the table that supports Tripwire
ALTER TRIGGER [dbo].[TriggerAddressUpdate]
ON [dbo].[tblAddress]
AFTER UPDATE
AS
SET XACT_ABORT ON
BEGIN DISTRIBUTED TRANSACTION
SET NOCOUNT ON;
--IF (SYSTEM_USER <> 'FHA\kYarberough' AND SYSTEM_USER <> 'FHA\ljlee' AND SYSTEM_USER <> 'FHA\PHarvey' AND SYSTEM_USER <> 'FHA\BShenosky' AND SYSTEM_USER <> 'FHA\BBrodie' AND SYSTEM_USER <> 'FHA\DRandolph')
Declare @UpdateID as varchar(50)
Set @UpdateID = newid()
BEGIN
INSERT [FHA-4].[ECMS_Audit].[dbo].[tblAddress_Audit]
([fldAddressOwnerID], [fldUpdateID], [fldAddressTypeCode], [fldAddressMailcode], [fldAddressSequence],
[fldAddressID], [fldName], [fldLine1], [fldLine2], [fldCity], [fldState], [fldCounty],
[fldZipcode], [fldWorkFax], [fldWorkPhone], [fldWorkExtension], [fldWorkEMail], [fldHomePhone],
[fldHomeEMail], [fldContactName], [fldContactPhone], [fldContactFax], [fldContactExtension], [fldEffectiveDate],
[fldExpirationDate], [fldUpdateTimestamp], [fldUpdateUserID], [fldRelationship], [fldNotes], [fldNCPDPNum],
[fldMedicaidNum], [fldStoreNum],
[ModifiedBySqlUser], [ModifiedByNTUser], [ModifiedDate], [Action] )
SELECT [fldAddressOwnerID], @UpdateID, [fldAddressTypeCode], [fldAddressMailcode], [fldAddressSequence],
[fldAddressID], [fldName], [fldLine1], [fldLine2], [fldCity], [fldState], [fldCounty],
[fldZipcode], [fldWorkFax], [fldWorkPhone], [fldWorkExtension], [fldWorkEMail], [fldHomePhone],
[fldHomeEMail], [fldContactName], [fldContactPhone], [fldContactFax], [fldContactExtension], [fldEffectiveDate],
[fldExpirationDate], [fldUpdateTimestamp], [fldUpdateUserID], [fldRelationship], [fldNotes], [fldNCPDPNum],
[fldMedicaidNum], [fldStoreNum],
CURRENT_USER, SYSTEM_USER, GETDATE(), 'InitialValues' FROM deleted
INSERT [FHA-4].[ECMS_Audit].[dbo].[tblAddress_Audit]
([fldAddressOwnerID], [fldUpdateID], [fldAddressTypeCode], [fldAddressMailcode], [fldAddressSequence],
[fldAddressID], [fldName], [fldLine1], [fldLine2], [fldCity], [fldState], [fldCounty],
[fldZipcode], [fldWorkFax], [fldWorkPhone], [fldWorkExtension], [fldWorkEMail], [fldHomePhone],
[fldHomeEMail], [fldContactName], [fldContactPhone], [fldContactFax], [fldContactExtension], [fldEffectiveDate],
[fldExpirationDate], [fldUpdateTimestamp], [fldUpdateUserID], [fldRelationship], [fldNotes], [fldNCPDPNum],
[fldMedicaidNum], [fldStoreNum],
[ModifiedBySqlUser], [ModifiedByNTUser], [ModifiedDate], [Action] )
SELECT [fldAddressOwnerID], @UpdateID, [fldAddressTypeCode], [fldAddressMailcode], [fldAddressSequence],
[fldAddressID], [fldName], [fldLine1], [fldLine2], [fldCity], [fldState], [fldCounty],
[fldZipcode], [fldWorkFax], [fldWorkPhone], [fldWorkExtension], [fldWorkEMail], [fldHomePhone],
[fldHomeEMail], [fldContactName], [fldContactPhone], [fldContactFax], [fldContactExtension], [fldEffectiveDate],
[fldExpirationDate], [fldUpdateTimestamp], [fldUpdateUserID], [fldRelationship], [fldNotes], [fldNCPDPNum],
[fldMedicaidNum], [fldStoreNum],
CURRENT_USER, SYSTEM_USER, GETDATE(), 'NewValues' FROM inserted
END
COMMIT TRANSACTION
SET XACT_ABORT OFF