SQL Bulk Copy Export - Output to Export file, Tab delimiter

Having a trouble on doing bulk copy export - I want to export a table data to text file output having tab as delimiter.

bcp "SELECT * FROM DatabaseLog" queryout TestingBulkCopy.txt -c -T

I am trying either on SQL 2008 or SQL 2012.
chokkaStudentAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mark WillsTopic AdvisorCommented:
Need to use "-t\t" as a parameter -t specifies the column delimiter and \t specifies the tab character
bcp "SELECT * FROM DatabaseLog" queryout "TestingBulkCopy.txt" -t\t -c -T 

Open in new window

And provide an output path as part of your output filename so you control where it goes...

Read https://docs.microsoft.com/en-us/sql/tools/bcp-utility

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chokkaStudentAuthor Commented:
Thank you ...!!

When i tried by passing with the folder path - I am getting syntax error - I am running the query in SQL 2012

bcp "SELECT * FROM DatabaseLog" queryout "C:\TestingBulkCopy.txt" -t\t -c -T
Mark WillsTopic AdvisorCommented:
possibly dont have write access to the root of C:\  

try creating a folder first and if need be right click to go into properties / security and allow access.

what was the error ?
Get Blueprints for Increased Customer Retention

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

chokkaStudentAuthor Commented:
Incorrect syntax near queryout - This has nothing to do with folder path permission
chokkaStudentAuthor Commented:
I tested the syntax in SQL 2012 and SQL 2008, I get incorrect syntax
Mark WillsTopic AdvisorCommented:
@chokka,

I am running it fine. Where and how are you running the BCP command ? Can you provide your code and details ?

T-SQL:
exec master..xp_cmdshell 'bcp "select * from testdb..yourtable" queryout "c:\test\ee\bcp_export_test.csv" -t\t -c -T'

Open in new window


And, what is the exact error message
Mark WillsTopic AdvisorCommented:
Hi Chokka,

Any more information to share ? Questions ? Error Messages ?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.