已知字段例如5101,如何查出字段如510102,510101这些之比已知多两个字符的字段

解决方案 »

  1.   

    字段名?..这个看要查系统表..得到列名..再用动态SQL..
      

  2.   

    select 字段 from 表 where 字段 like '5101%' and len(字段)=len('5101')+2
      

  3.   


    select * from tt where a like '5101%' and len(a)=6
      

  4.   

    select * from TableName where left(ColumnName) = '5101' and len(ColumnName) = 6
      

  5.   

    这样?
    select a.name,b.name from sysobjects a,syscolumns b
    where a.id=b.id
    and b.name like '5101%'
    and len(b.name)=len(5101)+2
      

  6.   

    不好意思,上面的漏了个参数,应该是这样:select * from TableName where left(ColumnName,4) = '5101' and len(ColumnName) = 6或者楼上各位用的 like 方法也可以