日期:2014-05-17  浏览次数:20933 次

Access中的val函数在SQL Server中怎么修改?
将读出的每一条记录的数值放入数组中,然后调用SQL语句中的Sum求和,部分代码如下:
    '找出本月进出口输单中
    set   rs=server.CreateObject( "adodb.recordset ")
    sql= "(select   distinct   HJ_DLDW   from   ImportWare   where   HJ_RQ   between   "&StartDate& "   and   "&EndDate& ")   union   "&_
            "(select   distinct   HJ_DLDW   from   ExportWare   where   HJ_RQ   between   "&StartDate& "   and   "&EndDate& ") "  
    rs.open   sql,db,3,3
    'Dim   DLDW_Array()
    do   while   not   rs.eof
          'response.Write   rs( "HJ_DLDW ")& " <br> "
  chosen   =   rs( "HJ_DLDW ")
          HJ_DLDW=HJ_DLDW&chosen& ", "

  rs.movenext
    loop
    DLDW_Array=split(HJ_DLDW, ", ")
......

    num=1

    for   i=0   to   Ubound(DLDW_Array)-1
            '出口
    set   rs1   =   server.createobject( "adodb.recordset ")
            sql1= "SELECT   count(*)   as   sumExp,   "&_
    "sum(val(HJ_YSBG))   as   sumYSBG,   "&_
    "sum(val(HJ_XMYKBG))   as   sumXMYKBG,   "&_
    "sum(val(HJ_YLBG))   as   sumYLBG,   "&_
            "sum(val(HJ_BQBG))   as   sumBQBG,   "&_
            "sum(val(HJ_TSBG))   as   sumTSBG,   "&_
    "sum(val(HJ_YSSJ))   as   sumYSSJ,   "&_
    "sum(val(HJ_XMYKSJ))   as   sumXMYKSJ,   "&_
            "sum(val(HJ_YSYHF))   as   sumYSYHF,   "&_
    "sum(val(HJ_XMYKYHF))   as   sumXMYKYHF,   "&_
            "sum(val(HJ_YSZK))   as   sumYSZK,   "&_
    "sum(val(HJ_XMYKZJ))   as   sumXMYKZJ   "&_
    "FROM   ExportWare   "&_
    "where   HJ_DLDW   =   ' "&Trim(DLDW_Array(i))& " '   and     (HJ_RQ   between   "&StartDate& "   AND   "&EndDate& ") "
            rs1.open   sql1,db,3,3
.....
好像在SQL   Server中不支持这个函数,想请教一下各位高手,应该如何解决?谢谢!

------解决方案--------------------
用Cdbl()试试
CDbl(str) --> 双精度
CInt(str) --> 整型
CLng(str) --> 长整型
CSng(str) --> 单精度
CDate(str) --> 日期型