Passing a value out of a Stored Procedure

  • I've created this procedure to count the number of times a particular condition was met in a log file.


    DECLARE @test-2 AS INT

    SELECT @test-2 = COUNT (*)

    FROM smtpstats

    Where clienthost = "" AND Operation = "Data" AND bytesrecvd > 200 AND bytesrecvd < 2000

    ??????????????NOW WHAT????????????????????????????


    Now I need to finish the procedure to pass the value of @test-2 to a single text box in an Interdev asp page. The code may be all wrong, or I may be going about this all wrong I'm just looking for the right direction.

  • You need to specify an OUTPUT parameter in your Create Proc statement, and assign the value of @test-2 to it. The resulting value will then be available for the process that called the SP.


  • You can also return the value back in a result set. There are pros / cons for using either an output argument or as a result set. Both work well. I usually make both available, using an optional parament '@select_ind'.

    - Brendan

Viewing 3 posts - 1 through 2 (of 2 total)

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