George2
George2

Reputation: 45771

export query results into CSV file issue in SQL Server

I am using SQL Server 2008 Enterprise. I want to export the query result into csv file from SQL Server Management Studio. The issue is, the default csv file is comma (',') separated for each result column in each exported row, and I want to make it '\t' separated since comma exists in some of the result column values.

Any quick solutions?

thanks in advance, George

Upvotes: 2

Views: 17463

Answers (3)

Raghav
Raghav

Reputation: 1

It saves only the 1st record as Tab delimited. I can't figur eout, how it will select all rows from query analyzer results section.

Upvotes: -1

Mark Dickinson
Mark Dickinson

Reputation: 6633

If you really want the \t delimiter write a query like this

select 
  Cast(PersonCode as varchar(50)) + '\t'
  + Cast(PersonReference as varchar(50))    
from People

The casts are just incase you aren't working with varchar types, but you don't need them if you are. Run this query with results to text and just paste the result into notepad or similar.

Upvotes: 5

Mitch Wheat
Mitch Wheat

Reputation: 300559

When you click "Save as" and you are prompted to enter a filename, drop down the box below the filename and select "Text (Tab delimited)"

Upvotes: 5

Related Questions