question

innovator avatar image
innovator asked

Dynamic new line to be inserted in data of text file that is exported through asp.net,database is sql server

I have a table A structure is given below where in If I export said table data to notepad or a file format .123,It should be exported in said file format ,according to column, I need to export data table a(col1,col2,col3,col4,col5,) For Ex-> I need to export data of col1,col2 and col3 in one line and data of col4 and col5 in next line Note -> Data between col1,col2 and col3 should not contain space in between them. Data is -> col1 col2 col3 col4 col5 1 2 3 4 5 Exported file should contain data as below-> 123 45 Thanx in advance Immediate reply would be apreciated
dynamicdataexport
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Usman Butt avatar image
Usman Butt answered
you can use query like SELECT ISNULL(CAST(col1 as VARCHAR(50)),'')+ISNULL(CAST(col2 as VARCHAR(50)),'')+ISNULL(CAST(col3 as VARCHAR(50)),'')+ CHAR(13) + CHAR(10) +ISNULL(CAST(col4 as VARCHAR(50)),'')+ISNULL(CAST(col5 as VARCHAR(50)),'') FROM yourtable
9 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

innovator avatar image innovator commented ·
thnx will check
0 Likes 0 ·
innovator avatar image innovator commented ·
Thnx for the suggestion,But I want to save said data in text file through asp.net C# code.doing R N D for the same.
0 Likes 0 ·
innovator avatar image innovator commented ·
will check and confirm
0 Likes 0 ·
innovator avatar image innovator commented ·
Usman thnx fot suggestion,But the real challenge for me is to save data of your mentioned select query into txt file,since data will be saved in dataset in .net, wanna save in text file.So thinking about string builder class!
0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.