SQL Server利用bcp命令把SQL语句结果生成文本文件
前端之家收集整理的这篇文章主要介绍了
SQL Server利用bcp命令把SQL语句结果生成文本文件,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在sql Server里可以调用DOS下的命令行工具bcp来实现把表里的数据或者sql语句结果生成文本文件。
BCP命令的参数格式:
<div class="codetitle"><a style="CURSOR: pointer" data="74619" class="copybut" id="copybut74619" onclick="doCopy('code74619')"> 代码如下:
<div class="codebody" id="code74619">
BCP {dbtable | query} {in | out | queryout | format} datafile
[-m maxerrors] [-f formatfile] [-e errfile]
[-F firstrow] [-L lastrow] [-b batchsize]
[-n native type] [-c character type] [-w wide character type]
[-N keep non-text native] [-V file format version] [-q quoted identifier]
[-C code page specifier] [-t field terminator] [-r row terminator]
[-i inputfile] [-o outfile] [-a packetsize]
[-S server name] [-U username] [-P password]
[-T trusted connection] [-v version] [-R regional enable]
[-k keep null values] [-E keep identity values]
[-h "load hints"]
_query_to_file.