Click here to Skip to main content
15,901,426 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted

1 solution

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

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900