This is test I have been working with but can't seem figure out what is wrong. I am trying to set variables that then be used to varify the data.
This is the Insert
And the error message
And just in case.
This is the table being inserted into
Thanks
John Fuhrman
Code:
USE [MailroomTracking_DEV]
GO
/****** Object: Trigger [dbo].[IO_TRIG_Insert_tblTrackingTable_Test] Script Date: 01/27/2011 16:41:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[IO_TRIG_Insert_tblTrackingTable_Test]
ON [dbo].[tblTrackingTable_Test]
Instead of Insert
AS
BEGIN
SET NOCOUNT ON
DECLARE @FileNumber varchar(15)
DECLARE @BoxNumber varchar(50)
DECLARE @TrackingDate datetime
DECLARE @Message varchar(250)
-- TODO: Set parameter values here.
Set @FileNumber = (Select FileNumber from Inserted)
Set @BoxNumber = (Select BoxNumber from Inserted)
Set @TrackingDate = (Select TrackingDate from Inserted)
Set @Message = @FileNumber + ' / ' + @BoxNumber + ' / ' + Cast(@TrackingDate as Varchar(15))
RAISERROR (@Message,16,1)
-- RAISERROR ('Deletions not allowed from this table (source = instead of)', 16, 1)
--EXECUTE [MailroomTracking_DEV].[dbo].[usp_TrackingInput_v6]
-- @FileNumber
-- ,@BoxNumber
-- ,@TrackingDate
END
This is the Insert
Code:
INSERT INTO [MailroomTracking_DEV].[dbo].[tblTrackingTable_Test]
(
[BoxNumber]
,[FileNumber]
)
VALUES
('nbc','a11111111')
And the error message
[red]
Msg 50000, Level 16, State 1, Procedure IO_TRIG_Insert_tblTrackingTable_Test, Line 21
[/red]
And just in case.
This is the table being inserted into
Code:
CREATE TABLE [dbo].[tblTrackingTable_Test](
[Tracking_ID] [int] IDENTITY(1,1) NOT NULL,
[EmployeeID] [varchar](50) NULL,
[MachineName] [varchar](20) NULL,
[BoxNumber] [varchar](45) NOT NULL,
[FileNumber] [varchar](25) NOT NULL,
[TrackingDate] [datetime] NULL,
[Reship] [bit] NULL,
[BoxNumberOriginal] [varchar](50) NULL,
[RowGUID] [uniqueidentifier] ROWGUIDCOL NOT NULL CONSTRAINT [DF_tblTrackingTable_Test_RowGUID] DEFAULT (newid()),
[RowDeleted] [bit] NULL CONSTRAINT [DF_tblTrackingTable_Test_RowDeleted] DEFAULT ((0)),
[ModifiedDate] [datetime] NULL,
[ModifiedBy] [varchar](25) NULL,
[TrackingYear] AS (datepart(year,[TrackingDate])),
[TrackingMonth] AS (datepart(month,[TrackingDate])),
[TrackingDay] AS (datepart(day,[TrackingDate])),
[FCO_PK] [int] NULL
) ON [PRIMARY]
Thanks
John Fuhrman