文章列表
时不时用到的sql:
1.利用spt_values生成规律数据,比如2个时间段内的日期:
SELECT DATEADD(DD,number,@BeginDate) AS [Date] FROM master.dbo.spt_values
WHERE type='P' AND number between 0 and DATEDIFF(DD,@BeginDate,@EndDate)-1
2.利用XML合并行数据为字符串:
with temp as
(
select 'a' as Content
union
select 'b' as Content
) ...