如何编写bcp命令在sql中创建头列? [英] How to write bcp command to create header columns in sql..?

查看:86
本文介绍了如何编写bcp命令在sql中创建头列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

exec master..xp_cmdshell 'BCP "select ''''empcode'''',''''fsname'''',''''ntype'''',''''desg'''',''''userid'''',''''dcr_count''''" queryout "d:\header.csv"  -c  -T -t'



,当我执行上述查询时,我会收到错误..我已经在下面进行了...请帮助我...




when i execute the above query i would get error..i have mentioed below..please help me out..

SQLState = 37000, NativeError = 102
Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near ''.
SQLState = 37000, NativeError = 8180
Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]Statement(s) could not be prepared.
NULL

推荐答案

你不能使用双引号

使用双单引号代替。它们应该可以正常工作:



you can't use double quotes
use double single quotes instead. They should work fine:

exec master..xp_cmdshell 'BCP ''select ''''empcode'''',''''fsname'''',''''ntype'''',''''desg'''',''''userid'''',''''dcr_count'''''' queryout ''d:\header.csv''  -c  -T -t'


这篇关于如何编写bcp命令在sql中创建头列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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