Dumb Question

  • Try this:

    declare @ss varchar(30)

    select @ss=[ProductID] from Product

    (Assuming that there is only a single value returned...)

  • Sorry. Did not read the complete post. 8-(

    Try this:

    declare @sql varchar(100)

    declare @ss varchar(30)

    declare @pid varchar(32)

    -- name of column

    set @ss='ProductID'

    -- returned value: productID

    set @pid=' '

    -- create global temp table

    select @pid into ##tmpretval where 0=1

    -- sql command string

    set @sql = "select [ + @ss + "] into ##tmpretval from Product "

    -- run it

    exec (@sql)

    -- fetch the value

    select @pid = [ProductID] from ##tmpretval

    -- drop the working table

    drop table ##tmpretval

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

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