I can't seem to add the filenumber case to it successfully.
Message:
[red]
Msg 209, Level 16, State 1, Procedure uTrackingTable, Line 12
Ambiguous column name 'FileNumber'.
Msg 209, Level 16, State 1, Procedure uTrackingTable, Line 13
Ambiguous column name 'FileNumber'.
Msg 209, Level 16, State 1, Procedure uTrackingTable, Line 14
Ambiguous column name 'FileNumber'.
Msg 209, Level 16, State 1, Procedure uTrackingTable, Line 12
Ambiguous column name 'FileNumber'.
Msg 209, Level 16, State 1, Procedure uTrackingTable, Line 14
Ambiguous column name 'FileNumber'.
Msg 209, Level 16, State 1, Procedure uTrackingTable, Line 14
Ambiguous column name 'FileNumber'.
Msg 209, Level 16, State 1, Procedure uTrackingTable, Line 15
Ambiguous column name 'FileNumber'.
Msg 209, Level 16, State 1, Procedure uTrackingTable, Line 15
Ambiguous column name 'FileNumber'.
[/red]
Thanks
John Fuhrman
Code:
USE [MailroomTracking]
GO
/****** Object: Trigger [dbo].[uTrackingTable] Script Date: 12/01/2010 16:44:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[uTrackingTable]
ON [dbo].[tblTrackingTable]
AFTER UPDATE
AS
BEGIN
SET NOCOUNT ON;
Update dbo.tblTrackingTable
Set ModifiedDate = getdate(),
-- Make all File Numbers 9 digit
[highlight]FileNumber = case
when ascii(substring(FileNumber,3,1))> 65 then FileNumber
when ascii(substring(FileNumber,2,1))> 65 then 'Second char LETTER'
when len(FileNumber)<10 then left(FileNumber,1) + replicate('0', 10-len(FileNumber))
+ right(FileNumber, len(FileNumber)-1) --pad with zeroes
end[/highlight]
From dbo.tblTrackingTable a
Inner Join Inserted As i
On a.Tracking_ID = i.Tracking_ID
END
Message:
[red]
Msg 209, Level 16, State 1, Procedure uTrackingTable, Line 12
Ambiguous column name 'FileNumber'.
Msg 209, Level 16, State 1, Procedure uTrackingTable, Line 13
Ambiguous column name 'FileNumber'.
Msg 209, Level 16, State 1, Procedure uTrackingTable, Line 14
Ambiguous column name 'FileNumber'.
Msg 209, Level 16, State 1, Procedure uTrackingTable, Line 12
Ambiguous column name 'FileNumber'.
Msg 209, Level 16, State 1, Procedure uTrackingTable, Line 14
Ambiguous column name 'FileNumber'.
Msg 209, Level 16, State 1, Procedure uTrackingTable, Line 14
Ambiguous column name 'FileNumber'.
Msg 209, Level 16, State 1, Procedure uTrackingTable, Line 15
Ambiguous column name 'FileNumber'.
Msg 209, Level 16, State 1, Procedure uTrackingTable, Line 15
Ambiguous column name 'FileNumber'.
[/red]
Thanks
John Fuhrman