试试:
QuerySBCL.SQL.Add('Where   substring(系统源槽路,5,5) between ''1'' and ''50'' ');

解决方案 »

  1.   

    QuerySBCL.SQL.Add('select * ');
    QuerySBCL.SQL.Add('from 设备槽路 ');
    QuerySBCL.SQL.Add('Where left(系统源槽路,10)>=''1-1-1'' left(系统源槽路,10)<=''1-1-50'' ');
      

  2.   

    结合top和like进行查询
    select top 50 * from xxx where fieldx like "1-1-%"
      

  3.   

    哦,刚才说的还有点问题,substring(系统源槽路,5,5) 你应该改成:
    substring(系统源槽路,5,length(rtrim(系统源槽路))-5). 
    因为你取得值可能为2或者更多位。
      

  4.   

    需要这么麻烦吗,直接选择就可以
    QuerySBCL.SQL.Add('select *                      ');
    QuerySBCL.SQL.Add('from 设备槽路                  ');
    QuerySBCL.SQL.Add('Where 系统源槽路 >= ''1-1-1''  ');
    QuerySBCL.SQL.Add('  and 系统源槽路 <= ''1-1-50'' ');字符串也可以比较的
      

  5.   

    QuerySBCL.SQL.Add('select * ');
    QuerySBCL.SQL.Add('from 设备槽路 ');
    QuerySBCL.SQL.Add('Where convert(int,substring(系统源槽路,5,2)>=1 and convert(int,substring(系统源槽路,5,2)<=50');
      

  6.   

    以上的各位都对,不过请注意所有SQL语句前或后记得加空格
      

  7.   

    QuerySBCL.SQL.Add('select * from 设备槽路 Where 系统源槽路 >= ''1-1-1'' and 系统源槽路 <= ''1-1-50'' ');
      

  8.   

    QuerySBCL.SQL.Add('select *');
    QuerySBCL.SQL.Add('from 设备槽路');
    QuerySBCL.SQL.Add('Where   convert(int,substring(系统源槽路,5,5)) between 1 and 50 ');
    中的convert(int,substring(系统源槽路,5,5))必须为表中的一个字段,
    否则编译会现你所提到的错误信息.
      

  9.   

    QuerySBCL.SQL.Add('select * ');
    QuerySBCL.SQL.Add('from 设备槽路 ');
    QuerySBCL.SQL.Add('Where (系统源槽路 between ''1-1-1''and ''1-1-50'')');
      

  10.   

    QuerySBCL.SQL.Add('select * ');
    QuerySBCL.SQL.Add('from 设备槽路 ');
    QuerySBCL.SQL.Add('Where rtrim(系统源槽路) between ''1-1-1'' and  ''1-1-50''');