Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2002
    Posts
    1

    Unhappy Unanswered: output parameter from temporary table

    I have a problem on how to get an output parameter from Temporary table. Do anyone have any idea on this case? Bellow is my my sample code. I get nothing return out when execute it. Thanks

    ====================================
    Create Proc pro_Temp

    @NTName VARCHAR(100) ='' OUTPUT

    AS

    Declare @strSQL VARCHAR(500)

    SET @strSQL = 'Select NTName FROM tblName'

    Create Table #Temp (NTName VARCHAR(100))
    Insert INTO #Temp
    exec (@strSQL)

    Select @NTNAme = NTName From #Temp
    ======================================

  2. #2
    Join Date
    Dec 2002
    Location
    Czech Republic
    Posts
    249

    Re: output parameter from temporary table

    --Try this code

    if object_id('tempdb..#Temp') is not null drop table #Temp
    if object_id('pro_Temp') is not null drop proc pro_Temp
    if object_id('tblName') is not null drop table tblName
    GO
    select distinct name as NTName
    into tblName
    from sysobjects
    GO
    Create Proc pro_Temp
    @NTName VARCHAR(100) ='' OUTPUT
    AS
    Declare @strSQL VARCHAR(500)
    SET @strSQL = 'Select NTName FROM tblName'
    Create Table #Temp (NTName VARCHAR(100))
    Insert INTO #Temp
    exec (@strSQL)
    Select @NTNAme = min(NTName) From #Temp
    GO
    declare @x varchar(100)
    exec pro_Temp @x OUTPUT
    select @x

Posting Permissions

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