2015-12-14 133 views
0

我在Access數據庫中有一堆的Yes/No字段,我需要進入SQL Server。如果我查看Access數據,那些字段包含0或-1。在SQL Server端我創建了並沒有對我的工作類型BIT的領域,我假設,因爲BIT預計0或1。這是我的錯誤:從MS Access導入數據到SQL Server的問題

The given value of type String from the data source cannot be converted to type bit of the specified target column. ---> 
System.FormatException: Failed to convert parameter value from a String to a Boolean. 
String was not recognized as a valid Boolean 

我也使用爲nvarchar(3)也做了嘗試不工作,說「從數據源類型字符串的給定值不能轉換爲類型nvarchar」

我應該使用哪種數據類型?我試過BIT,TINYINT,NVARCHAR(3),CHAR(1)和CHAR(2)。

使用CHAR(1)或CHAR(2)給了我一個不同的錯誤:

System.Data.SqlClient.SqlException (0x80131904): Received an invalid column length from the bcp client for colid 13. 

但沒有任何一種方式工作

回答

0

在導入過程中使用了一下,你會想要做的是從一個轉換到1號和爲0,你可以使用一個CASE語句來處理此操作。

IE

CASE WHEN colVal = 'Yes' THEN 1 ELSE 0 
+0

不幸的是,我不能更改導入的包 – ElenaDBA

相關問題