SQL表值函数(上月添加1-28)

 1 ALTER function [dbo].[fn_getdate3]
 2 (
 3     @cc varchar(15)
 4 )
 5 RETURNS
 6 @Table_Var TABLE 
 7 (
 8     LastTime datetime
 9 )
10 as 
11 begin
12 Declare @rand float
13 Declare @num Int
14 set @num=6
15 while (@num>5 and @num<15) 
16 begin 
17 select @rand=re from v_RAND
18 insert into @Table_Var
19 select dateadd(day,@rand*28,[Date]) from A01 Where ID=@num
20 set @num=@num+1
21 end
22 return
23 END
原文地址:https://www.cnblogs.com/slmdr9/p/5843539.html