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]
where DutyDate between A and B
exec("select * from DutyInfo pivot (max([DutyName]) for [DutyDate] in("+@s+"))b ")
/pre>
40分
declare @s nvarchar(4000)
Select @s=isnull(@s+",","")+quotename([DutyDate])
from DutyInfo group
where DutyDate between A and B
y [DutyDate]
exec("select * from DutyInfo pivot (max([DutyName]) for [DutyDate] in("+@s+"))b ")
/pre>