Friday, June 26, 2009

Tabs In SQL

When trying to create a tab delimited file recently, I ran into the problem that the text field I was trying to pull back as the Description column contained tabs and these were causing issues with the rest of my query. To solve this little problem, I used SQL's replace function as follows:

REPLACE(CAST(Description AS VARCHAR(7500)), CHAR(13), ' ')
This could result in some truncating if the Description is very long, but it served my purpose just fine.

No comments:

Post a Comment