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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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
0

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
0
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 ?
0
The Five Tenets of the Most Secure Backup

Data loss can hit a business in any number of ways. In reality, companies should expect to lose data at some point. The challenge is having a plan to recover from such an event.

chokkaStudentAuthor Commented:
Incorrect syntax near queryout - This has nothing to do with folder path permission
0
chokkaStudentAuthor Commented:
I tested the syntax in SQL 2012 and SQL 2008, I get incorrect syntax
0
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
0
Mark WillsTopic AdvisorCommented:
Hi Chokka,

Any more information to share ? Questions ? Error Messages ?
0
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.