1、查询数据,赋值给变量

  1. -- 手工报送成功
  2. BEGIN
  3. declare @rptbatch varchar(64)
  4. declare @status varchar(2)
  5. set @status = 92 --修改状态
  6. select @rptbatch = rptbatch from sysconfig; --查询数据赋值给变量
  7. update sysconfig set status = @status where 1=1;
  8. update reportprocess set status=@status where rptbatch = @rptbatch;
  9. update formsprocess set status=@status where rptbatch = @rptbatch;
  10. select * from sysconfig;
  11. END

2、给某时间列赋予任意时间值

  1. declare @date_start datetime
  2. declare @date_end datetime
  3. set @date_start= '2020-06-01'
  4. set @date_end=getdate()
  5. update USER_LOG set OCCUR_TIME = dateadd(minute,abs(checksum(newid()))%(datediff(minute,@date_start,@date_end)+1),@date_start) where 1=1