日期:2014-05-17 浏览次数:20610 次
declare @s nvarchar(4000)
Select @s=isnull(@s+',','')+quotename([DutyDate])
from DutyInfo group by[DutyDate]
exec('select * from DutyInfo pivot (max([DutyName]) for [DutyDate] in('+@s+'))b')
declare @s nvarchar(4000)
Select @s=isnull(@s+',','')+quotename([DutyDate])
from DutyInfo group by[DutyDate]
exec('select * from DutyInfo pivot (max([DutyName]) for [DutyDate] in('+@s+'))b
order by case
when dutyweek=''星期一'' then 1
when dutyweek=''星期二'' then 2
when dutyweek=''星期三'' then 3
when dutyweek=''星期四'' then 4
when dutyweek=''星期五'' then 5
when dutyweek=''星期六'' then 6
when dutyweek=''星期日'' then 7 END ')
string str = "declare @s nvarchar(4000) Select @s=isnull(@s+',','')+quotename([DutyDate]) from DutyInfo where DutyDate between'" + DateTime.Now.ToString("yyyyMMdd") + "'and'" + dt.ToString("yyyyMMdd") + "'group by [DutyDate] exec('select * from DutyInfo)a pivot (max([DutyName]) for [DutyDate] in('+@s+'))b order by case when Dutyweek=''星期一'' then 1 when Dutyweek=''星期二'' then 2 when Dutyweek=''星期三'' then 3 when Dutyweek=''星期四'' then 4 when Dutyweek=''星期五'' then 5 when Dutyweek=''星期六'' then 6 when Dutyweek=''星期日'' then 7 END ')";