Results 1 to 3 of 3

Thread: parameter returned by a execute

  1. #1
    Join Date
    Dec 2003
    Posts
    14

    Question parameter returned by a execute

    Hello,

    How can I pass the value of the count(*) to outside the execute. I need the value to continue with the sp

    set @sql= 'declare @res int select @res=count(*) from t
    where tam=(select '+@posxx+' from sffpoxx0 where ponbr='+@Col001+' and poodn='+@Col002+' and pocat='+@Col007+')'

    ???????? set @result=exec (@sql) ????????????? Something like this


    Thanks
    Paulo

  2. #2
    Join Date
    Mar 2004
    Location
    Canada
    Posts
    7
    try this

    select @countWidget = count(Widget)
    from WidgetFile

    Print @countWidget

    Simon

  3. #3
    Join Date
    Mar 2004
    Posts
    1
    I think, the EXEC statement cannot reurn OUTPUT parameters directly when TSQL script is run, instead a stored proc with an OUTPUT param can be run with the EXEC.
    You can use sp_executesql to achieve this...
    DECLARE @sql nvarchar(2000),@count INT
    set @sql= 'select @var1=count(*) from t'
    EXEC sp_executesql @sql,N'@var1 INT OUT',@count OUT
    Last edited by jk121; 03-09-2004 at 11:21 PM.

Posting Permissions

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