Results 1 to 3 of 3
  1. #1
    Join Date
    May 2010
    Posts
    1

    Unanswered: Help needed with Stored Procedure

    Hi

    I am trying to change the integer value passed from the website to alphabet using stored procedure. But I seem to be doing it wrongly.

    Code:
    ALTER PROCEDURE [dbo].[Attendance_AddAttendance]
    
    -- Add the parameters for the stored procedure here
    
    @AdmNo nvarchar(20),
    @Present bit,
    @Latecoming bit,
    @AbsentReason nchar(1),
    @AttendDate nvarchar(10),
    @Remarks text
    
    AS
    BEGIN
    
    SELECT @AbsentReason = CASE @AbsentReason WHEN 0 THEN 'M'
    WHEN 1 THEN 'C'
    WHEN 2 THEN 'X'
    WHEN 3 THEN 'O'
    WHEN 4 THEN 'V'
    ELSE 'R'
    END CASE
    
    -- Insert statements for procedure here
    INSERT into attendance
    (attendanceDate,admissionNo,present,latecoming,AbsentReasonID,Remarks)
    
    VALUES
     (@AttendDate,@AdmNo,@Present,@Latecoming,@AbsentReason,@Remarks)
    END
    After I added the Case, it throws this error, "Msg 156, Level 15, State 1, Procedure Attendance_AddAttendance, Line 34
    Incorrect syntax near the keyword 'CASE'."

    Thank you.

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Just END, not END CASE

  3. #3
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •