Re: how to return a value in a stored procedure?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



You need to use an output parameter. Have a look at these:

http://msdn2.microsoft.com/en-us/library/ms971497.aspx
http://www.sommarskog.se/share_data.html
http://www.informit.com/articles/article.aspx?p=25288&seqNum=9&rl=1


--
Andrew J. Kelly SQL MVP
Solid Quality Mentors


"Chris" <ch@xxxxxxx> wrote in message news:%23TUm6byIIHA.5860@xxxxxxxxxxxxxxxxxxxxxxx
Hi,

i use a stored procedure for my asp.net application which must return a value: (number of items). How can i do that?
I tried this but don't know how to giive te found value back.
Thansk
Chris


ALTER PROCEDURE [dbo].[mysp]

AS
declare @returnValue int
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
select COUNT(DISTINCT numberofitems) from items
END

set @returnValue = ???
return @returnValue



.



Relevant Pages

  • Re: how to return a value in a stored procedure?
    ... Solid Quality Mentors ... i use a stored procedure for my asp.net application which must return a ... declare @returnValue int ... -- SET NOCOUNT ON added to prevent extra result sets from ...
    (microsoft.public.sqlserver.connect)
  • Re: how to return a value in a stored procedure?
    ... Dim intRa, intIdentity As Integer ... declare @returnValue int ... -- SET NOCOUNT ON added to prevent extra result sets from ...
    (microsoft.public.sqlserver.connect)
  • how to return a value in a stored procedure?
    ... i use a stored procedure for my asp.net application which must return a ... declare @returnValue int ... -- SET NOCOUNT ON added to prevent extra result sets from ... select COUNT(DISTINCT numberofitems) from items ...
    (microsoft.public.sqlserver.connect)
  • Re: Adding date to parameter
    ... ClaimedDate does appear to have a properly formatted date. ... I am using the following stored procedure: ... -- SET NOCOUNT ON added to prevent extra result sets from ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Using DTS to Insert 1 Second record for every second in a month?
    ... Okay...so you basically need a calendar table by seconds. ... And yes that will perform pretty fast for the type of query ... >set NoCount OFF ... >This stored procedure took about 21 minutes. ...
    (microsoft.public.sqlserver.dts)