0

I am exporting a big SSMS query result (2M lines, 1 column) to a CSV file.

Each row may contain multiple words.

Is it possible to tokenize each line, such that every "space" character encountered will be comma-delimited?

For example (column header not included)

Database column:

The quick brown fox  
Jumps over the lazy dog

Query result in CSV file:

The,quick,brown,fox  
Jumps,over,the,lazy,dog
Dale K
  • 25,246
  • 15
  • 42
  • 71
Marss
  • 573
  • 2
  • 7
  • 24
  • 1
    https://stackoverflow.com/questions/21226107/sql-server-bulk-insert-csv-with-data-having-comma – CR241 Mar 12 '20 at 21:57

1 Answers1

0

I suggest doing that in the query itself rather than using SSMS - just use a replace function:

SELECT REPLACE([MyCol], ' ', ',');

Then in SSMS export options turn text-qualifiers off.

I'm sure you're aware but and it's your intention but this will destroy your nice tabular data into a ragged edge!

Mark Taylor
  • 1,128
  • 8
  • 15