Delphi 项目由Access升级到SQLServer2005的注意事项

Delphi项目由Access升级SQLServer2005的过程中的注意事项如下:
1)Access中的自增字段在SQLServer2005中默认是Int型非自增字段,需要将其改为BigInt型自增字段。
    Delphi 项目由Access升级到SQLServer2005的注意事项_第1张图片
  2)日期型查询的区别。
     Access中要加#号如:SQLStr := SQLStr +' and buyDate >= #'+FormatDateTime('yyyy-MM-dd',Dtp_BuyDateSHStart.Date)+
         '# and buyDate <= #'+FormatDateTime('yyyy-MM-dd',Dtp_BuyDateSHEnd.Date)+'#';
 SQLServer中要加""号如: SQLStr := SQLStr +' and buyDate >= '''+DateToStr(Dtp_BuyDateSHStart.Date)+
            ''' and buyDate <= '''+DateToStr(Dtp_BuyDateSHEnd.Date)+'''';
 Access中日期参数必须是字符串如:
                         SQLStr := SQLStr +' and regDate >=:a and regDate <=:b';
                          Parameters.ParamByName('a').Value := FormatDateTime('yyyy-MM-dd',Dtp_RegDateStart.Date);
                          Parameters.ParamByName('b').Value := FormatDateTime('yyyy-MM-dd',Dtp_RegDateEnd.Date);
  SQLServer中日期参数可以是字符串也可以是日期如:
                         SQLStr := SQLStr +' and regDate >=:a and regDate <=:b';
                          Parameters.ParamByName('a').Value := Dtp_RegDateStart.Date;
                          Parameters.ParamByName('b').Value := Dtp_RegDateEnd.Date;
                          //Parameters.ParamByName('a').Value := FormatDateTime('yyyy-MM-dd',Dtp_RegDateStart.Date);
                          //Parameters.ParamByName('b').Value := FormatDateTime('yyyy-MM-dd',Dtp_RegDateEnd.Date);
                              
 3)like查询语句。
      Access中like和参数后可以有空格也可以没有如:SQLStr:='select * from customertb where cardNum like:a '
      SQLServer中like和参数后必须有空格如:SQLStr:='select * from customertb where cardNum like :a '

4)对于默认值字段需要重新指定。



你可能感兴趣的:(Delphi 项目由Access升级到SQLServer2005的注意事项)