Results 1 to 4 of 4

Thread: exec statement

  1. #1
    Join Date
    Mar 2004
    Posts
    25

    Unanswered: exec statement

    hi guys

    maybe an easy one for you

    in stored procedure I create follving select

    @cmd = 'select ' + @column_name + 'from ticket_dump_datawarehouse '
    execute (@cmd)

    problem is thant I want to gave return value from this select

    something like
    set @return = execute(@cmd)

    but I recieve error

    Incorrect syntax near the keyword 'execute'

    Can I do that some other way?

  2. #2
    Join Date
    Mar 2004
    Posts
    80

    Re: exec statement

    return
    which value?
    Originally posted by mikosan
    hi guys

    maybe an easy one for you

    in stored procedure I create follving select

    @cmd = 'select ' + @column_name + 'from ticket_dump_datawarehouse '
    execute (@cmd)

    problem is thant I want to gave return value from this select

    something like
    set @return = execute(@cmd)

    but I recieve error

    Incorrect syntax near the keyword 'execute'

    Can I do that some other way?

  3. #3
    Join Date
    Mar 2004
    Posts
    25
    this is whole select.

    sorry I forgot to finish it

    @cmd = 'select ' + @column_name + 'from ticket_dump_datawarehouse where id = 10'

    execute (@cmd)

    value from select statement = value in column @column_name

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Code:
    USE Northwind
    GO
    
    DECLARE @sql varchar(8000), @OrderId int
    
    SELECT @SQL = 'SELECT TOP 1 OrderId INTO myTable99 FROM Orders'
    
    EXEC(@SQL)
    
    SELECT @OrderId = OrderId FROM myTable99
    
    SELECT @OrderId
    GO
    
    DROP TABLE myTable99
    GO
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

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