--在mssql 2005的查询中,是这样子的,符合要求:
select no, sname from tableinfo
 where isnull(dutystate, '') <> isnull('离职', '')
//在delphi 2010 中,不管怎么写,总是出错,得不到 mssql 中那个 “离职”中的单引号。
  var Sdutys,QrySql:string;
  Sdutys:='离职';
  QrySql := 'select no, sname from tableinfo'+
             ' where isnull(dutys, '') <> isnull('+#39+Sduty+#39+', '')';
//也试过这样的:
  AQrySql := 'select no, sname from tableinfo'+
             ' where isnull(dutys, '') <> isnull('+''''+Sdutys+''''+', '')';我记得我在delphi中就用过,比如:  AQrySql := 'select no, sname from tableinfo'+
             ' where dutys='+''''+Sdutys+''''; //这里得到的就是mssql中的单引号啊。为什么 这样子的呢?谢谢大家了啊。

解决方案 »

  1.   

    SQL字符串中的单引号能不能用"英文双引号代替
    我在ACCESS中都是用双引号
      

  2.   

     AQrySql := 'select no, sname from tableinfo'+
                 ' where isnull(dutys, '''') <> isnull('''+Sdutys+''', '''')';
      

  3.   


     QrySql := 'select no, sname from tableinfo'+
                 ' where isnull(dutys, '''') <> <> isnull(''离职'', '''')';
      

  4.   


    //这个
     QrySql := 'select no, sname from tableinfo'+
                 ' where isnull(dutys, '''') <>isnull(''离职'', '''')';
      

  5.   


    AQrySql := 'select no, sname from tableinfo'+
                 ' where isnull(dutys, '''') <> isnull(''离职'', '''')';
      

  6.   

    --在mssql 2005的查询中,是这样子的,符合要求:
    select no, sname from tableinfo
     where isnull(dutystate, '') <> isnull('离职', '')
    '在DELPHI中是转义字符  两个顶一个便可了
      

  7.   

    isnull(dutys, '')     =>        isnull(dutys, '''')