SQL Server导入向导将NULL视为文字字符串'NULL' [英] SQL Server Import Wizard treats NULL as literal string 'NULL'
本文介绍了SQL Server导入向导将NULL视为文字字符串'NULL'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试将.csv逗号分隔的平面文件导入Microsoft SQL Server 2008R2 64位实例时,对于字符串列,原始数据中的NULL变为文字字符串NULL,并且在我收到的数字列中导入错误。谁能请帮忙???在此先感谢!
When I attempt to import a .csv comma-delimited flat file into a Microsoft SQL server 2008R2 64-bit instance, for string columns a NULL in the original data becomes a literal string "NULL" and in a numeric column I receive an import error. Can anyone please help??? Thanks in advance!
推荐答案
将数据放入临时表,然后使用SQL代码插入生产表。
Put the data into a staging table and then insert to the production table using SQL code.
update table1
set field1 = NULL
where field1 = 'null'
或者如果你想做很多字段
Or if you want to do a lot of fields
update table1
set field1 = case when field1 = 'null' then Null else Field1 End
, field2 = case when field2 = 'null' then Null else Field2 End
, field3 = case when field3 = 'null' then Null else Field3 End
这篇关于SQL Server导入向导将NULL视为文字字符串'NULL'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文