我怎樣才能插入一個空白的日期到SQL數據庫在ssis使用Visual Basic腳本組件? 我不得不從Excel轉移日的數據庫,我想在數據庫中插入一個空白或空值,如果在Excel中是空SSIS我怎樣才能插入一個空白的日期數據庫與視覺基本
感謝
我怎樣才能插入一個空白的日期到SQL數據庫在ssis使用Visual Basic腳本組件? 我不得不從Excel轉移日的數據庫,我想在數據庫中插入一個空白或空值,如果在Excel中是空SSIS我怎樣才能插入一個空白的日期數據庫與視覺基本
感謝
通過空白你的意思是默認的日期,或保持它空值??
而不是將空白日期插入到SQl服務器中,您是否可以不在SQL表本身中設置默認日期,以便在沒有任何內容傳遞到該字段時自動執行此操作?
在腳本組件中,創建一個新的輸出列 - 類型爲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
我必須將日期從Excel轉移到數據庫,如果在Excel中爲空,我想在數據庫中插入一個空值或空值 – simone 2009-11-23 10:13:44