We use a program called Fedex ShipManager. It integrates with a SQL 2008 database. I am trying to write a trigger that will copy some of what the fedex software writes to a different database. I have checked, there is no way to get the software to write to two separate databases. This trigger works when I insert the data, but it fails when the fedex software does it. Does anyone have any guesses as to why this would happen?
ALTER TRIGGER [dbo].[trg_FulfilmentRequest] ON [Billing].[dbo].[ShipmentBilling] AFTER INSERT AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; --Check if the ReferenceCode is numberic DECLARE @ShipRequest varchar(50) SELECT @ShipRequest = ReferenceCode FROM INSERTED IF ISNUMERIC(@ShipRequest) = 1 Begin --If the Reference Code is numberic convert it to an integer DECLARE @ShipRequestID INT SET @ShipRequestID = CONVERT(INT, @ShipRequest) --If the ReferenceCode is in CatalogData.dbo.ShipmentRequest IF EXISTS (SELECT * FROM [CatalogData].[dbo].[ShipmentRequest] WHERE [CatalogData].[dbo].[ShipmentRequest].[ShipmentRequestID] = @ShipRequestID) BEGIN --Insert the data into CatalogData.dbo.ShippingInformation DECLARE @TrackingNum varchar(50) SELECT @TrackingNum = TrackingNumber FROM INSERTED INSERT INTO [CatalogData].[dbo].[ShippingInformation] (ShipmentRequestId, TrackingNumber) VALUES (@ShipRequestID, @TrackingNum); END END END
I have tried commenting out various lines. It is the insert statement that causes the problem. It also causes the problem if the TrackingNumber is removed.
Thanks for any suggestions