Results 1 to 2 of 2

Thread: exec statement

  1. #1
    Join Date
    Mar 2004

    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
    Dec 2003
    create temporary table out the and insert the result into that table
    create table #t(colvalue <datatype>)

    @cmd = 'insert into #t (colvalue)
    select ' + @column_name + 'from ticket_dump_datawarehouse '
    execute (@cmd)

    select * From #t

    drop table #t

Posting Permissions

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