Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2006
    Posts
    47

    Unanswered: Seting a variable value from a select statment

    In my sproc this is wrong :

    SELECT @DetailItems= Count(idDetail)
    FROM Details
    WHERE CheckNum=@CheckNumber

    How should i do this?


    Create PROC voidCks
    @CheckNumber varchar(30)
    AS
    DECLARE @DetailItems int,
    @DetailTotal MONEY,
    @CheckAmount MONEY,

    SELECT @DetailItems= Count(idDetail)
    FROM Details
    WHERE CheckNum=@CheckNumber

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    If you need the value outside the stored procedure, you could return it as an output parameter. Or, you could try to return it as a return value, but then you are stuck with a single value.

  3. #3
    Join Date
    Apr 2006
    Posts
    47
    i dont need it outside the sp, i am using it to make sure the # of items affected in the delete match the # found in the select

    oops spelling erorr

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Describe what is wrong... That looks kosher to me.

    -PatP

Posting Permissions

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