SQL Server BCP:如何在所有字段引号? [英] SQL Server BCP: How to put quotes around all fields?

查看:844
本文介绍了SQL Server BCP:如何在所有字段引号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个BCP命令:

'bcp DBName..vieter out c:\test003.txt -c -T /t"\",\"" -S SERVER'

不要在字段名称周围加引号,而是将其放在逗号周围!如何获取 / t\,\在所有字段中加上引号。

The output CSV I get does not put quotes around the field names, instead it puts it around the commas! How can I get the /t"\",\"" to put quotes around all fields.

感谢所有

推荐答案

除了字段终止符外,还应设置行终结符。

Setting the row terminator in addition to the field terminator should do the trick

'bcp DBName..vieter out c:\test003.txt -c -T -t"\",\"" -r"\"\n\"" -S SERVER'

这可能会工作,领导第一行的第一个字段,也许最后一个,我不确定,只是猜测真的,这里没有服务器!

This will likely work, but miss of the leading " for the first field of the first line, and perhaps the last of the last, i'm not sure, just guessing really, no server here!

或尝试使用QUOTENAME包装文本字段(也可以包装数字,但通常不需要。

or try using QUOTENAME to wrap text fields (you could also wrap numbers, but that isn't normally required.

'bcp "SELECT id, age, QUOTENAME(name,'"') FROM DBName..vieter" queryout c:\test003.txt -c -T -t"," -S SERVER'

这篇关于SQL Server BCP:如何在所有字段引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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