表中有个字段为:id,sql语句大致要表达的意思是:select * from table where
length(id) = 6,当然了,这样写肯定会报错,那我该怎么写那?

解决方案 »

  1.   

    select * from tablename where trim(id)=6
      

  2.   

    select * from dbo.TB6007A where(rtrim( 小磁架))=20
    ltrim and rtrim 是SQLSERVER 提供的!
      

  3.   

    如果要提供你所说的LENGTH则用程序实现,用一个临时表!
      

  4.   

    好像不行啊,trim函数sqlserver不认,然后ltrim and rtrim 检索不出结果的
      

  5.   

    select * from table where len(id) = 6
      

  6.   

    procedure TForm1.Button1Click(Sender: TObject);
    var i:integer;
      I,j: Integer;
    begin
    table1.First;
    i:=table1.fieldcount;
    while not table1.eof do
    begin
     if length(table1.FieldByName('id').AsString)=6 then
        begin
         table2.Append;
         for j := 0 to i-1 do    // Iterate
         begin
          table2.Fields[j].Value:=table1.Fields[j].Value;
         end;    // for
        end;
     Table1.Next;
     datasource1.DataSet:=table2;
     table2.Active:=true;
    end;    // while
    end;
    给一段代码!
      

  7.   

    trim 是删除空格的 ltrim rtrim 左删除 右删除
    没有length 难道就没有len 了吗?还是看看帮助吧