Solved

How to export BCP with Pipe Delimiter

Posted on 2015-01-12
4
1,304 Views
Last Modified: 2015-01-14
Hi..
What is the syntax to export with a pipe '|' as delimiter


this if for CSV or comma


set @s = 'bcp "'+ @SQL + '" queryout ' + @FilePath + ' -c -t, -T'
exec master..xp_cmdshell @s
0
Comment
Question by:JElster
  • 2
4 Comments
 
LVL 49

Expert Comment

by:Vitor Montalvão
ID: 40546873
Delimiter for what? Field or row?
Field delimiter: set @s = 'bcp "'+ @SQL + '" queryout ' + @FilePath + ' -c -t ¦ -T'
Row terminator: set @s = 'bcp "'+ @SQL + '" queryout ' + @FilePath + ' -c -t, -T -r ¦'
0
 
LVL 1

Author Comment

by:JElster
ID: 40546878
field
0
 
LVL 49

Expert Comment

by:Vitor Montalvão
ID: 40546886
Then is the first solution. You defined as comma so you just need to change it to pipe.
0
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 40548894
Note that the pipe character is a special character to the command interpreter. You need to escape it using the Circumflex character:
set @s = 'bcp "'+ @SQL + '" queryout ' + @FilePath + ' -c -t^| -T'

Open in new window

0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question