Solved

How to export BCP with Pipe Delimiter

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

Expert Comment

by:Vitor Montalvão
Comment Utility
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
Comment Utility
field
0
 
LVL 45

Expert Comment

by:Vitor Montalvão
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now