rt

解决方案 »

  1.   

    用列的序号,首先要到syscolumns中去找
      

  2.   

    例的序号=XX。这个XX是什么呢,是号码的话,和例名=XX有什么区别
      

  3.   

    select *,identity(1,1) taoistong into #taoistong from 表
    select * from #taoistong where taoistong=列的序号
      

  4.   


    --> 测试数据:[tb]
    if object_id('[tb]') is not null drop table [tb]
    go
    create table [tb]([编号] varchar(7),[时间] datetime,[数量] int)
    insert [tb]
    select '0100001','2009-09-28 13:18:00.000',18 union all
    select '0100002','2009-09-28 13:18:00.000',29 union all
    select '0100002','2009-09-28 13:45:00.000',15 union all
    select '0100003','2009-09-28 13:45:00.000',42 union all
    select '0100004','2009-09-28 13:45:00.000',11 union all
    select '0100001','2009-09-28 13:45:00.000',12 union all
    select '0100003','2009-09-29 10:45:00.000',18 union all
    select '0100004','2009-09-29 10:45:00.000',20 
    declare @colorder int
    set @colorder=3 --列的序号declare @name varchar(50)
    select @name= name  from syscolumns  where id=object_id('tb') and colorder=@colorder
    exec('select * from tb where '+@name+'=12')/*编号      时间                      数量
    ------- ----------------------- -----------
    0100001 2009-09-28 13:45:00.000 12(1 行受影响)
    */
      

  5.   

    嗯,应该利用系统表,SYSCOLUMNS,SYSOBJECTS来求出你的列,再得到列名,
      

  6.   

    补充: 我这里要在asp里实现  如何实现?