简体   繁体   English

无法使BCP将数据从视图导出到CSV

[英]Can't makes BCP to export data from view to csv

Thanks to domenicr now I see, that bcp keys are case sensetive. 感谢domenicr现在,我知道bcp键区分大小写。 But another problem appears - bcp asks me about type of the field to write in file each time i run script - is it possible to automate that? 但是出现另一个问题-每次我运行脚本时bcp询问我要写入文件的字段类型-是否可以自动执行?

Enter the file storage type of field Employee_ID [char]:

I need to export data from view to csv file. 我需要将数据从视图导出到csv文件。 The easiest way, as it seems to me is BCP. 在我看来,最简单的方法是BCP。 I tried to read MSDN https://msdn.microsoft.com/en-us/library/ms162802.aspx for syntax help, but I can't makes bcp to create file cause of error (running bcp from cmd). 我试图阅读MSDN https://msdn.microsoft.com/zh-cn/library/ms162802.aspx以获取语法帮助,但是我无法使bcp创建文件错误原因(从cmd运行bcp)。 Thanks in advance for any help with syntacsis. 在此先感谢您对语法的任何帮助。

bcp [base_name].[dbo].[all_users_for_ad] out 1.csv -t -c -u mylogin -p mypassword -s mysever


bcp:  unknown option u
usage: 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"]         [-x generate xml format file]

BCP command arguments are case sensitive. BCP命令参数区分大小写。 Should be -T and -S. 应该是-T和-S。 For trusted connections, no need to pass user and password. 对于可信连接,无需传递用户名和密码。

Use -c to specify character data type or supply a format file with -f argument 使用-c指定字符数据类型或使用-f参数提供格式文件

Refer to this on how to create a format file. 有关如何创建格式文件的信息,请参考此内容。 https://msdn.microsoft.com/en-CA/library/ms191516.aspx https://msdn.microsoft.com/zh-CN/library/ms191516.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM