为什么当列包含空字符串时bcp输出为空,而当列为空字符串时为什么bcp输出为空? [英] Why does bcp output null when the column contains an empty string and empty string when the column is null?

查看:250
本文介绍了为什么当列包含空字符串时bcp输出为空,而当列为空字符串时为什么bcp输出为空?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这让我感到很奇怪,我花了一段时间检查代码中的错误,然后才发现

This struck me as really weird behaviour and I spent a while checking for bugs in my code before I found this

"out从数据库表或视图复制到文件.如果指定现有文件,则该文件将被覆盖.提取数据时,请注意bcp实用程序将空字符串表示为null,将空字符串表示为空字符串." (来自 http://msdn.microsoft.com/en-us/library/ms162802 .aspx )

"out copies from the database table or view to a file. If you specify an existing file, the file is overwritten. When extracting data, note that the bcp utility represents an empty string as a null and a null string as an empty string." (from http://msdn.microsoft.com/en-us/library/ms162802.aspx)

很显然,这使我可以解决问题,但是有人可以想到还是有人知道这种情况的原因?

Obviously this allowed me to fix my problem but can anybody think of or does anybody know a reason why this is the case?

推荐答案

已经有一段时间了,但是我敢肯定,这是SQL Server 6.5的向后兼容性/旧版本.

It's been some time, but I'm sure it's a backwards compatibility/legacy back to SQL Server 6.5

SQL Server 6.5无法存储空字符串:总有一个空格.这在SQL 7中已更改

SQL Server 6.5 could not store empty string: there was always one space. This changed with SQL 7

从古代历史的角度来看,'' -> NULL' ' -> ''是正确的.

So '' -> NULL and ' ' -> '' is correct from an ancient history perspective.

这篇关于为什么当列包含空字符串时bcp输出为空,而当列为空字符串时为什么bcp输出为空?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆