Match : Input value =Column Name

  • I have the below senario.

    Create table Emp

    (

    Ecode_12345 varchar(25),

    Ecode_54321 varchar(25),

    Ecode_98765 varchar(25)

    )

    insert into Emp

    Select 'Salary-12500','Salary-30000','Salary-50000'

    union all

    Select 'Age-25','Age-37','Age-42'

    Now my requirement is, if i give 12345 as the parameter, i want the Ecode_12345 details.

    Say for example,

    Create procedure p1

    (

    @Ecode int

    )

    as

    begin

    end

    exec p1 12345

    will display the below result.

    Salary-12500

    Age-25

    Inputs are welcome !

    karthik

  • create procedure proc1 (@i int)

    as

    declare @sql varchar(1000)

    select @sql="select field"+@i" from "

    exec (@sql)

    go

    I havent tested the procedure myself. I hope you get an idea.

    Cheers

    Amit

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

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