"SELECT field(1) FROM Inserted", exist?

  • I would select a field value by the position

    of the column in the table inserted and

    delete, because the name of the column is

    uncnoun (I write a trigger for all tables).

    if you have a methode to do this, i will be

    happy, thanx, regards mourad.

  • Well, your explaination of what you're after is not all that clear, but how about adapting:...

    declare @TableName varchar(255)

    declare @PosWanted int

    declare @ColWanted varchar(255)

    declare @Columns table

    (

    Position int identity(1,1),

    ColName varchar(255)

    )

    set @TableName = 'TableName'

    set @PosWanted = 5

    insert into @Columns (colname)

    select name from syscolumns where id = object_ID(@TableName) order by ColOrder

    set @ColWanted = (select ColName from @Columns where Position = @PosWanted)

    exec ('select ' + @ColWanted + ' from ' + @TableName)

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

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