BCP命令如何给出Pipe Seperated文件 [英] How BCP command giving Pipe Seperated file
问题描述
下面是我的代码,因为我正在获取有效文件,其中sperator是tab但我想将Pipe字符作为sperator。
Below is my code as i am getting valid file where sperator is tab but i want Pipe character as sperator.
DECLARE @FileName varchar(50), @bcpCommand varchar(2000)
SET @FileName = 'E:\dd.txt '
SET @bcpCommand = 'bcp "select top 10 * from MyTable" queryout "'
SET @bcpCommand = @bcpCommand + @FileName + ' -U sa -P Pwd -c'
print @bcpCommand
EXEC master..xp_cmdshell @bcpCommand
推荐答案
谷歌针对bcp分离器的第一和第二个结果:
指定字段和行终止符 [ ^ ]
bcp Utility [< a href =http://msdn.microsoft.com/en-GB/library/ms162802.aspxtarget =_ blanktitle =New Window> ^ ]
你需要使用-t
参数(区分大小写)来指定字段分隔符。
First and second results from Google for "bcp separator":
Specify Field and Row Terminators[^]
bcp Utility[^]
You need to use the-t
argument (case sensitive) to specified the field separator.
-t field_term
指定字段终止符。默认值为\t(制表符)。使用此参数可覆盖默认字段终止符。有关详细信息,请参阅指定字段和行终止符 [ ^ ]。
如果在bcp.exe命令中以十六进制表示法指定字段终止符,则该值将在0x00处截断。例如,如果指定0x410041,则将使用0x41。
如果field_term以连字符( - )或正斜杠(/)开头,请不要包含-t和field_term值之间的空格。
-t field_term
Specifies the field terminator. The default is \t (tab character). Use this parameter to override the default field terminator. For more information, see Specify Field and Row Terminators[^].
If you specify the field terminator in hexadecimal notation in a bcp.exe command, the value will be truncated at 0x00. For example, if you specify 0x410041, 0x41 will be used.
If field_term begins with a hyphen (-) or a forward slash (/), do not include a space between -t and the field_term value.
这篇关于BCP命令如何给出Pipe Seperated文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!