Update Stored Procedure

  • I am trying to write my first stored procedure and have consulted BOL etc. Can someone help me finish this simple SP to update fields in the ApptOVDetail table after user enters values in unbound controls in the FE:

    CREATE PROCEDURE dbo.procApptOVDetailUpdate (@nApptID int)

    FOR UPDATE

    AS

     (

     SELECT

     ovd.ApptReasonCode,

     ovd.RadiolInfoCode,

     ovd.MammTime,

     ovd.CXRTime

     FROM ApptOVDetail ovd

     

     WHERE ovd.AppointmentID=@nApptID

    )

    I don't know why my where statement turned blue but I can't get it to stop!!

    Thanks, guys!!

    SMK

  • CREATE PROCEDURE dbo.procApptOVDetailUpdate (@nApptID int, @reason varchar, @cxrtime int)

    AS

     update ovd

        set ovd.apptreasoncode = @reason SELECT

           , cxrtime = @cxrtime

     FROM ApptOVDetail ovd

     

     WHERE ovd.AppointmentID=@nApptID

    return

     

  • Steve:

    From your example, I got this far:

    CREATE PROCEDURE dbo.procApptOVDetailUpdate (@nApptID int, @ApReason int, @Radiol int, @mammTime int, @cxrTime int)

    AS

    Update ovd

        set ovd.ApptReasonCode = @ApReason

        set ovd.RadiolInfoCode=@Radiol

        set ovd.CXRTime=@cxrTime 

        set ovd.MammTime=@mammTime

    SELECT

    FROM ApptOVDetail ovd

     

     WHERE ovd.AppointmentID=@nApptID

    return

    Do I not need all those "set"s?

    SMK

  • SMK,

    Quote:

    I don't know why my where statement turned blue but I can't get it to stop!!

    UnQuote.

    Put a space before and after the equal sign. Since there isn't a space before the @ symbol it thinks it's a URL.

    Test:

    sometext@sometext  blue/thinks it's a URL

    sometext @ sometext  not blue

     

    -SQLBill

  • I think I have it now. I replaced the "set" with commas and my syntax is successful now.

    I will post back if I still can't get it to work.

    Thanks!!!

    SMK

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply