I have a table with some columns with data as large as 8000 characters. For some of the records in my table, I wanted to export this information into a text file so that I can manually go through some records. So essentially I have a table like this:
Col1 | Col2 | 开发者_高级运维Col3
---------------------
A1 | A2 | A3
B1 | B2 | B3
which I want to format into the following form and write into a text file:
Col1:
A1
Col2:
A2
Col3:
A3
Col1:
B1
Col2:
B2
Col3:
B3
Can someone please suggest a way of achieving this?
select 'Col1:' + char(13) + Char(10) + Col1 + char(13) + Char(10)
+ 'Col2:' + char(13) + Char(10) + Col2 + char(13) + Char(10)
+ 'Col3:' + char(13) + Char(10) + Col3 + char(13) + Char(10)
+ char(13) + Char(10)
from table
EDIT: And you have to make sure you have selected 'Results to Text' instead of 'Results to grid' in the Microsoft SQL Server Management Studio
精彩评论