Solved

How to export BCP with Pipe Delimiter

Posted on 2015-01-12
4
1,177 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 47

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 47

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

This is basically a blog post I wrote recently. I've found that SARGability is poorly understood, and since many people don't read blogs, I figured I'd post it here as an article. SARGable is an adjective in SQL that means that an item can be fou…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

778 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