SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2008
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MS SQL return value from stored procedure

    Hello guys.
    Having difficulty with my first attempt at returning values from a stored procedure... can anyone cast any light on it please?

    Here is a snippet.

    Code SQL:
    ALTER PROCEDURE [dbo].[ds_get_id] 
    	(
    		@ds_id INT output
    	)
    AS
    SELECT top 1 it_request_id_int FROM requests ORDER BY it_request_id_int DESC
     
    /*
    above returns 70, as expected
    now i want to set @ds_get_id = 70
    and return the value 
    */

    Simply - I don't know how I can assign the result of the select statement to @ds_id to send it back to my code.

    Thanks in advance.

  2. #2
    SitePoint Guru
    Join Date
    Jan 2004
    Location
    Uppsala, sverige
    Posts
    698
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Code:
    SELECT @ds_id = top 1 it_request_id_int FROM requests ORDER BY it_request_id_int DESC


Bookmarks

Posting Permissions

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