作业调度

declare @data datetime , @userID int,@now varchar(20) ,@date varchar(20)
set @now =(select convert(varchar(20),year(getdate()))+convert(varchar(20) ,month(getdate()))+convert(varchar(20) ,day(getdate())))
DECLARE authors_cursor CURSOR FOR
SELECT StudyDate, UserID FROM StudyNotes as SN
WHERE StudyDate  in (SELECT max(StudyDate) FROM StudyNotes WHERE UserID=SN.UserID )
OPEN authors_cursor
-- Perform the first fetch.
FETCH NEXT FROM authors_cursor into @data,@userID
-- Check @@FETCH_STATUS to see if there are any more rows to fetch.
WHILE @@FETCH_STATUS = 0
BEGIN
   -- This is executed as long as the previous fetch succeeds.
  set @date=(select convert(varchar(20),year(@data))+convert(varchar(20) ,month(@data))+convert(varchar(20) ,day(@data)))
  if(@date<@now)
     begin
    insert into StudyNotes (StudyName,StudyDate,UserID) values('你'+@date+'没记笔记哦!',getdate(),@userID)
    print @date+'这是date'+@now+'这是now'
     end
   FETCH NEXT FROM authors_cursor into @data, @userID

END
CLOSE authors_cursor
DEALLOCATE authors_cursor
GO

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值