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

 

posted @ 2016-09-05 20:42  温故余学  阅读(253)  评论(0编辑  收藏  举报