sql server 生成连续日期和数字
在sqlserver里,可以利用系统表master..spt_values里面存储的连续数字0到2047,结合dateadd()函数生成连续的日期。
selectconvert (varchar(10),dateadd(d, number, getdate()),23) as workday from master..spt_values where type = 'p' and number between 1 and 365
select number from master..spt_values where type = 'p' and number between 1 and 10 /*String_Split是SQLServer 2016的新函数,这个方法只对2016及后续版本有效。*/ select row_number() over (order by (select 1)) from String_Split(space(6),' ')