• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 83
  • Last Modified:

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.
0
chokka
Asked:
chokka
  • 4
  • 3
2 Solutions
 
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
 
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now