SQL Server bcp 及 NullIf 的使用
来源:互联网 发布:防伪底纹设计软件 编辑:程序博客网 时间:2024/05/16 08:42
bcp
The bcp utility bulk copies data between an instance of Microsoft SQL Server 2005 and a data file in a user-specified format. Thebcp utility can be used to import large numbers of new rows into SQL Server tables or to export data out of tables into data files. Except when used with thequeryout option, the utility requires no knowledge of Transact-SQL. To import data into a table, you must either use a format file created for that table or understand the structure of the table and the types of data that are valid for its columns.
Syntax
bcp {[[database_name.][owner].]{table_name | view_name} | "query"} {in | out | queryout | format} data_file [-mmax_errors] [-fformat_file] [-x] [-eerr_file] [-Ffirst_row] [-Llast_row] [-bbatch_size] [-n] [-c] [-w] [-N] [-V (60 | 65 | 70 | 80)] [-6] [-q] [-C { ACP | OEM | RAW | code_page } ] [-tfield_term] [-rrow_term] [-iinput_file] [-ooutput_file] [-apacket_size] [-Sserver_name[\instance_name]] [-Ulogin_id] [-Ppassword] [-T] [-v] [-R] [-k] [-E] [-h"hint [,...n]"]
ULLIF (Transact-SQL)
Returns a null value if the two specified expressions are equivalent.
Syntax
NULLIF ( expression , expression )
注意事项:
对于 bcp ,需要注意:
1, 其中的SQL Script 语句不可换行,必须在一行内写完,否则会无法执行。
2, 其参数中 -c 及 -w 会导致不同的txt 文件格式,ANSI 和 unico 格式
为何要将此两项放在一块说明,因近期发现并解决了一个问题,原因正是出在bcp 输出txt 文件时,最终必须使用 NULLIF 才能正常将相关Column Value 输出为一个可以被其它系统功能识别的txt 文件。否则会将显示为一个 Null 值,(字段间使用 tab 分隔) 导致其它功能导入此txt 文件时,获取空字段值时取得的值却显示为#符号,使用Notepad+ 检查发现此符号显示为Null。
使用NullIf 方式处理,如 NullIf(column1, ' ') 即判断字段值是否为一个空白字符串,如是则显示为Null ,否则显示为正常的 Column Value,如此处理后,竟然结果OK了,Notepad+ 中不再显示为Null,在其它功能导放此txt 文件时也不再显示为#。
很奇怪但也算了解了NULLIF 的特别使用方式。
- SQL Server bcp 及 NullIf 的使用
- sql server BCP 工具的使用
- SQL Server BCP使用小结
- SQL Server BCP使用小结
- SQL Server BCP使用小结
- SQL Server BCP使用小结
- SQL Server里的 ISNULL 与 NULLIF
- SQL Server里的 ISNULL 与 NULLIF
- SQL Server里的 ISNULL 与 NULLIF
- SQL SERVER 2008---NULLIF
- SQL Server 使用BCP导出数据
- SQL Server使用bcp导入导出
- sql server 使用bcp 导入导出数据
- SQL Server BCP 导入导出使用
- sql server 的 bcp 导入导出
- sql server的BCP导入导出
- sql server的BCP导入导出
- SQL Server大容量复制实用工具bcp下载安装及使用
- Linux on the i.MX6 sabre sd platform in a few commands
- LCD 驱动
- WinForm 怎样关闭登陆窗体
- 用开源组件jcaptcha做jsp彩色验证码
- UITableView: textLabel,detailTextLabel
- SQL Server bcp 及 NullIf 的使用
- 模板类声明和定义为何要写一起
- 内存分析工具 MAT 的使用
- 删除老的 provisioning profile 如何删除xcode中的多余证书
- JavaScript String 对象
- android大扫盲之SurfaceView,SurfaceHolder,SurfaceHolder.CallBack.
- 【bdump】bdump目录下产生大量cdmp_2014xxx和死锁信息
- android release export has encountered a problem
- error LNK2001: unresolved external symbol "__declspec(dllimport) const CNoteMgr::`vftable'"