Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 Other Topics
 Export to Excel Question

Author  Topic 

ldiggins
Starting Member

1 Post

Posted - 2012-02-06 : 19:09:46
Hey guys, so ive created a simple timecard form for some staff member to fill out daily. It has a few fields. Jobsite, starttime, endtime, lunchin, lunchout, description, materials used.
It repeats for upto 3 jobs (our guys work around alot during the day)
When i export into excel its basically one long row all fields. Is there a way to export basically ONE jobsite, and then next jobsite info below the first one? So instead of Looking like this:
Employee,date,jobsite,timein,timeout,lunchout,lunchin,description,jobsite2,timein2,lunchin2,lunchout2....ect
it would look like this
Employee,date,jobsite,timein,timeout,lunchin,lunchout,description
NEXT ROW DOWN
jobsite,timein,timeout...ect

Any thoughts? Not thats is a super big issue to cut the row where needed and paste below, just hoping to save a little time.
Thanks in advance

Lloyd

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-06 : 20:26:08
i think you need to use ssis and in it apply unpivot transformation to get the details from columns to seperate rows.
Another way is to use OPENROWSET and use query like

SELECT Employee,date,jobsite,timein,timeout,lunchout,lunchin,description
FROM OPENROWSET(...)
UNION ALL
SELECT Employee,date,jobsite2,timein2,timeout2,lunchout2,lunchin2,description2
FROM OPENROWSET(...)
..


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -