2016-02-04 84 views
0

我有一個來自csvde的csv文件,它具有objectGUID和來自AD的一些其他信息。SSIS如何將對象轉換爲SQL的varBinary

我想使用SSIS此信息複製下面的表格到SQL

從CSVDE文件
[DN] [varchar](255) NULL, 
[ObjectGuid] [varbinary](50) NULL, 
[pwdExpiry] [bigint] NULL 

示例CSV文件看起來像這樣:

DN,objectGUID,msDS-UserPasswordExpiryTimeComputed 
"CN=DEFRAVMDROOTCA1,OU=Test,DC=company,DC=net",X'c7eb536bc818f842bde11d8152755e7e',9223372036854775807 
"CN=Sajeed Temp,OU=Test,DC=company,DC=net",X'417979aad0a9cc49818d1960ec95fb80',130834271604215531 
"CN=IAMToolset.2,OU=Test,DC=company,DC=net",X'5a936d02842275458c45c1eb932a0f67',130849689154565841 
"CN=IAMToolset.3,OU=Test,DC=company,DC=net",X'c03d2d11f8d8fe40a0eac70d41f3e1fd',130849689796313340 
"CN=IAMToolset.4,OU=Test,DC=company,DC=net",X'e8b084e9d8c4a8428284ecb40b628da8',130849690015854425 
"CN=IAMToolset.5,OU=Test,DC=company,DC=net",X'4b4e17dfce09e049941f3bd0ecddd5bb',130849690271803391 
"CN=IAMToolset.6,OU=Test,DC=company,DC=net",X'004454a17c997b43af8e4b2653b491c2',130849690477125089 
"CN=IAMToolset.7,OU=Test,DC=company,DC=net",X'8f70d9c64514c1409364624e3b079d42',130849690693072263 
"CN=IAMToolset.8,OU=Test,DC=company,DC=net",X'ff70df18badafb4491225b29470b9a3d',130849690864329935 
"CN=IAMToolset.9,OU=Test,DC=company,DC=net",X'a081e666a2df3c4481a4f124b489fdd8',130849691049650737 
"CN=IAMToolset.1,OU=Test,DC=company,DC=net",X'8c59987d0a5c2a4ea1e98d07a84e1144',130849691453887596 
"CN=testmigration,OU=Test,DC=company,DC=net",X'a800d0e29335d248ad990ad31fd5dd52',130732638130905654 
"CN=DEFRAVMDPKMCA1,OU=Test,DC=company,DC=net",X'0d67d30bcbbbed48af9ed7736f9b1992',9223372036854775807 

我有SSIS包有兩個連接管理者。其中之一是爲平面文件,我正在讀取作爲字符串從csv列objectGUID。問題是我想將數據流任務中的這個列轉換爲可以推送到SQL表中的[ObjectGuid] varbinary NULL列的格式。

我已經使用數據轉換轉換並嘗試轉換爲DT_GUID和DT_BYTES,但是在運行該程序包時,它們在該數據轉換步驟都失敗。

所以,我真的希望看到的是,如果我在CSV文件中有一個的objectGUID爲

X'168dea153aab0a45adf8079b94041e90' (串) 我想看看它在SQL表作爲 0x168DEA153AAB0A45ADF8079B94041E90(VARBINARY)

我得到SSIS運行時錯誤是:

Error: 0xC02020C5 at Data Flow Task, Data Conversion [2]: Data conversion failed while converting column "ObjectGuid.LeftCleaned" (16) to column "Copy of ObjectGuid.LeftCleaned" (6). The conversion returned status value 2 and status text "The value could not be converted because of a potential loss of data.". 
Error: 0xC0209029 at Data Flow Task, Data Conversion [2]: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "Data Conversion.Outputs[Data Conversion Output].Columns[Copy of ObjectGuid.LeftCleaned]" failed because error code 0xC020907F occurred, and the error row disposition on "Data Conversion.Outputs[Data Conversion Output].Columns[Copy of ObjectGuid.LeftCleaned]" specifies failure on error. An error occurred on the specified object of the specified component. There may be error messages posted before this with more information about the failure. 
Error: 0xC0047022 at Data Flow Task, SSIS.Pipeline: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "Data Conversion" (2) failed with error code 0xC0209029 while processing input "Data Conversion Input" (3). The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running. There may be error messages posted before this with more information about the failure. 

請幫

回答

0

我相信關鍵在這裏:

「由於數據可能丟失,無法轉換該值。」

確定您已經給予了足夠大的長度到數據轉換任務,以適應在CSV最大可能值。另一方面,您需要確保該列在轉換後可以保存相同數量的數據。

DataConversionLength

+0

Thans Phil。我做到了。該錯誤消失了,但現在還有其他錯誤。 – gtrivedi

+0

我加了128,但是我知道他們在數據庫列中不應該超過50。 – gtrivedi