returning value from stored procedure

  • i have one stored procedure that i want to execute it and get the result. all that in a query window.

    the procedure:

    USE [xxx]

    GO

    /****** Object: StoredProcedure [dbo].[sp_AddNewsletter] Script Date: 06/27/2008 11:40:27 ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    ALTER PROCEDURE [dbo].[sp_AddNewsletter]

    (@IDSite [bigint],

    @Name [varchar](50),

    @Email [varchar](50),

    @Invalue int output

    )

    AS

    --verificar se o e-mail já esta cadastrado

    SELECT [Name] FROM [xxx].[dbo].[Newsletter] WHERE Email=@Email AND IDSite=@IDSite

    IF @@ROWCOUNT=0

    BEGIN

    INSERT INTO [xxx].[dbo].[Newsletter]

    ( [IDSite],

    [Name],

    [Email])

    VALUES

    ( @IDSite,

    @Name,

    @Email)

    set @Invalue = 1

    Return @Invalue

    END

    else

    begin

    set @Invalue = 0

    Return @Invalue

    end

    that procedure is not returning 1 or 0 when i execute it.

    this is how im executing it:

    use xxx

    go

    Declare @Invalue int

    declare @IDSite int

    declare @name nvarchar(200)

    declare @email nvarchar(200)

    set @IDSite = 1

    set @name = 'il'

    set @email = 'il@web.com'

    exec sp_Addnewsletter @IDSite, @name, @email, @Invalue output

    go

    why am i not getting the correct value? ( 0 or 1 )

    thanks in advance for any help

  • Have you tried adding a select after the exec command?

    exec sp_Addnewsletter @IDSite, @name, @email, @Invalue output

    select @Invalue as Invalue

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

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

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