if DTSSource("Spot-start")="[?]" then  ----增加[]
    DTSDestination("Spot-start") = null
 else DTSDestination("Spot-start") =  DTSSource("Spot-start")
 end if

解决方案 »

  1.   

    datetime类型
    怎么会有“?”
    格式错误啊,不能插入
      

  2.   

    不是将“?”插入啊,是做判断后啊!如果是“?”,就插NULL;如果不是“?”,就插入原来的值,而且这个值一定是合法的
      

  3.   

    是不是将
    if DTSSource("Spot-start")="?" then
        DTSDestination("Spot-start") = null
     else DTSDestination("Spot-start") =  DTSSource("Spot-start")
     end if
    中的"?"换为'?'
    ???窃以为。
      

  4.   

    我按照你说的做了,程序没有问题!是不是 数据的原因,比如?是汉字的?,再看看数据?后面有无空格,看看excel列格式是文本还是数字的?
      

  5.   

    to:笨笨!你按照我的做法没问题么?但是它可以将“?”转换成NULL,但却认不出时间啊。我怀疑是不是在SQL里“?”是代表任意字符的呢?
      

  6.   

    没有问题,你可以新作一个excel,然后添加一些数据,再试试程序,我怀疑是数据问题
      

  7.   

    if DTSSource("Spot-start") like '%[?]%' then  ----增加[]
        DTSDestination("Spot-start") = null
    else 
        DTSDestination("Spot-start") = DTSSource("Spot-start")
    end if
      

  8.   

    我试了一下,怎么会报错的呢?
    我要导入下面的这些数据
    Last-update Last-inv-date
    2003-9-2          ?
    ?          2006-6-3
    ?          ?
    ?          ?
    ?          1931-3-3
    ?          ?
    ?          2025-12-2
    ?          ?
    ?          2007-1-3
    ?          1930-4-3
    有那位大虾帮我试一下!!不胜感激!!
      

  9.   

    我试过左边的数据导入后为null右边Last-inv-date导入没有问题。看了一下粘贴到excel的数据,发现2003-9-2单元格格式为日期,微软导入程序对excel导入支持不好,跟数据类型有关,很多时候会出现错误,我一般都是先把excel导成有分隔符文本,然后再导入到sql中!
      

  10.   

    我的代码
    Function Main()
    if isdate(DTSSource("Last-update")) then  
         DTSDestination("Last-update") = DTSSource("Last-update")
    else 
         DTSDestination("Last-update") =  null
    end if
    if isdate(DTSSource("Last-inv-date"))  then  
         DTSDestination("Last-inv-date") = DTSSource("Last-inv-date")
    else 
         DTSDestination("Last-inv-date") =  null
    end if
    Main = DTSTransformStat_OK
    End Function
      

  11.   

    你可以试试把Last-update头几个数据改一下,比如2003-9-1等,单元格格式也改成基本,
    再导入就可以看到数据!
      

  12.   

    to 笨笨:我按照你的做法做了啊,可是还是都是NULL的,一点反映都没有,这究竟是什么问题呢?