Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / August 2007

Tip: Looking for answers? Try searching our database.

Text File Reporting

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
RP - 28 Aug 2007 14:35 GMT
I am using C# with SQL Server 2005.

I have a table that looks like this:

EmpID         Code
-----------        --------
101        A1
101        B1
101        C1

102        A1
102        C1

103        B1
103        D1

I want to write like this in a text file:

EmpID    A1    B1    C1    D1
-----------------------------------------------
101    10      20       10       0
102    100      0       150      0
103    0     100       0      120
----------------------------------------------

Firstly, how to convert column values into row. Secondly, while
writing into text file, I want the column headings and later the
records below in a fixed size so that they align with the headings.
Ignacio Machin ( .NET/ C# MVP ) - 28 Aug 2007 15:57 GMT
Hi,

Sql 2005 provides a way to convert rows into columns , take a look at Pivot
Formatting it is easy, you can do it from SQL itself, just use char columns

>I am using C# with SQL Server 2005.
>
[quoted text clipped - 24 lines]
> writing into text file, I want the column headings and later the
> records below in a fixed size so that they align with the headings.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.