I am stuck on creating a Stored Procedure that has a CASE in it for validataing file numbers.
Output
Thanks
John Fuhrman
Code:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- ======================================================================
-- Author: John F Fuhrman
-- Create date: 10/12/2010
-- Description: Stored Procedure for Data Input into the Tracking Table.
-- ======================================================================
CREATE PROCEDURE usp_TrackingInput
-- Add the parameters for the stored procedure here
@FileNumber VarChar = Null,
@BoxNumber VarChar = Null,
@TrackingDate DateTime = GetDate()
AS
BEGIN
SET NOCOUNT ON;
Insert Into dbo.tblTrackingTable (EmployeeID, MachineName, BoxNumber, FileNumber, TrackingDate)
Values
Case
When @FileNumber like '[a-zA-Z][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
(PARSENAME(REPLACE(SUSER_SNAME(), '\', '.'), 1),Host_Name(),@FileNumber,@BoxNumber,@TrackingDate)
Case
When @FileNumber like '[a-zA-Z][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
(PARSENAME(REPLACE(SUSER_SNAME(), '\', '.'), 1),Host_Name(),@FileNumber,@BoxNumber,@TrackingDate)
Case
When @FileNumber like '[a-zA-Z][a-zA-Z][a-zA-Z][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
(PARSENAME(REPLACE(SUSER_SNAME(), '\', '.'), 1),Host_Name(),@FileNumber,@BoxNumber,@TrackingDate)
Case
When @FileNumber like '[a-zA-Z][a-zA-Z][a-zA-Z][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
(PARSENAME(REPLACE(SUSER_SNAME(), '\', '.'), 1),Host_Name(),@FileNumber,@BoxNumber,@TrackingDate)
Case
When @FileNumber like '.BOX.END.'
(PARSENAME(REPLACE(SUSER_SNAME(), '\', '.'), 1),Host_Name(),@FileNumber,@BoxNumber,@TrackingDate)
Else
RAISERROR(50500,16,1)
END
GO
Output
Code:
Msg 102, Level 15, State 1, Procedure usp_TrackingInput, Line 12
Incorrect syntax near '('.
Msg 156, Level 15, State 1, Procedure usp_TrackingInput, Line 19
Incorrect syntax near the keyword 'Case'.
Thanks
John Fuhrman