October 21, 2004 at 6:41 am
I have a text data type column in SQL Server. I want to export that data to text file using the bcp utility. Each row in the column has to be split into several lines while exporting to text file. For example the data 'abcd \n efgh' has to be exported into text file with abcd on one line and efgh on the next line.
Please suggest what character I shoul include in the data so as to cause the data to split while exporting to text file.
Thanks
Regards
Satish
October 21, 2004 at 6:47 am
CHAR(13) "Carriage Return" and possibly follow with CHAR(10) "Line Feed"
--Jeff Moden
Change is inevitable... Change for the better is not.
October 26, 2004 at 2:48 am
Thanks Jeff
I had actually tried using char(13) and char(10) nut it didnt help
Regards
October 26, 2004 at 5:05 am
Jeff's answer should work, eg
bcp "select 'abcd'+CHAR(13)+CHAR(10)+'efgh'" queryout test.txt -S servername -T -c
will produce a text file with
abcd
efgh
Far away is close at hand in the images of elsewhere.
Anon.
October 29, 2004 at 2:25 am
Thanks Jeff and David
It works.
Seems I was trying char(10) and char(13) in the wrong order.
It works only in a specific order
First char(13) and then char(10)
Thanks again
Sunny
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply