2009-11-23 27 views

回答

2

通過空白你的意思是默認的日期,或保持它空值??

而不是將空白日期插入到SQl服務器中,您是否可以不在SQL表本身中設置默認日期,以便在沒有任何內容傳遞到該字段時自動執行此操作?

+0

我必須將日期從Excel轉移到數據庫,如果在Excel中爲空,我想在數據庫中插入一個空值或空值 – simone 2009-11-23 10:13:44

4

在腳本組件中,創建一個新的輸出列 - 類型爲DATE。這會將它作爲可寫對象在腳本中的對象模型中公開 - 將有一個值爲Row.COLUMNNAME,值爲Row.COLUMNNAME_IsNull。推測你的輸入列是作爲字符串列來的。

然後,在腳本中,設置Row.COLUMNNAME_IsNull = True當在合適的條件得到滿足,例如,(這是生產代碼,具有preCOMPDATE字符串列來自源,並在輸出端的COMPDATE日期欄):

If Row.preCOMPDATE_IsNull Then 
    ' In this example we only set it to NULL is the string is null - you might also do this for blanks or whatever else the string might contain 
    Row.COMPDATE_IsNull = True 
Else 
    ' This is a date cleansing routine defined elsewhere in the script - out of range dates are defaulted to 1/1/1900, among other things, logging errors and setting severities 
    Row.COMPDATE = ValidateDate("COMPDATE", _ 
           Row.preCOMPDATE, _ 
           startDate, _ 
           endDate, _ 
           New Date(1900, 1, 1), _ 
           ErrorDesc, _ 
           IsRegDtError) 
End If 
相關問題