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.
| Author |
Topic |
|
kieran5405
Yak Posting Veteran
96 Posts |
Posted - 2009-09-14 : 11:48:07
|
| Hi,I need to copy the results of a tsql statement into excel. All works except for where an int field (days) is greater than 1. In these cases I need to have the int value of rows in the excel sheet i.e. in my results...if (days) field is 15...then i must represent this as 15 rows in the excel sheet (all of these rows would be the same).Rather than going through the 1000's of rows in excel and copyng/pasting where the field is > than 1...is there any way to do this in my query...i tried using the 'case' scenerio but its not working for me. Is there something better im missing??? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-09-14 : 11:51:23
|
| yup. you can use cross join based on column value for repeating rows that many times. if you need more info, post some sample data |
 |
|
|
kieran5405
Yak Posting Veteran
96 Posts |
Posted - 2009-09-14 : 12:01:16
|
| cheers for that...say for example... select nt_name, no_days_off from tblLeave |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-09-14 : 13:08:06
|
for repeating this it will be something likeselect t.nt_name, t.no_days_off from tblLeave tcross join master..spt_values vwhere v.type='p'and v.number between 1 and t.no_days_off |
 |
|
|
kieran5405
Yak Posting Veteran
96 Posts |
Posted - 2009-09-14 : 13:26:18
|
| another sql area i never heard off!! thanks for that...it worked perfectly...would have been messing with it til doomsday!!! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-09-14 : 13:27:56
|
ok..welcome |
 |
|
|
|
|
|