类别:数据库
日期:2021-02-26 浏览:1307 评论:0
USE [lxkeji] GO /****** Object: StoredProcedure [dbo].[usp_DataPager] Script Date: 02/25/2021 14:38:10 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO alter PROCEDURE [dbo].[usp_YYDate] AS BEGIN declare @timeCount datetime = null declare @ID int declare @yyDate datetime declare @ShiftDateID int declare @ShiftID int declare @ShiftDateTime datetime declare @ShiftDateState int declare @QueueID nvarchar(100) declare @CRUser varchar(50) declare @HosID nvarchar(50) declare cursor1 cursor for select ShiftDateID,ShiftID,ShiftDateTime,ShiftDateState,QueueID,CRUser,HosID from IN_DocQueueDateTB where ShiftDateTime > DATEADD(DAY,-7,(select top 1 ShiftDateTime from IN_DocQueueDateTB where del='0' order by ShiftDateTime desc)) open cursor1 fetch next from cursor1 into @ShiftDateID,@ShiftID,@ShiftDateTime,@ShiftDateState,@QueueID,@CRUser,@HosID while @@fetch_status = 0 begin print @timeCount if (@timeCount is null) begin print '111' set @yydate=DATEADD(DAY,1,getdate()) end else begin print '222' if (@timeCount!=@ShiftDateTime) begin print '3333' set @yydate=DATEADD(DAY,1,@yydate) end end print @yydate insert into IN_DocQueueDateTB (ShiftID,ShiftDateTime,ShiftDateState,QueueID,CRUser,CRDate,Del,HosID) values (@ShiftID,@yydate,@ShiftDateState,@QueueID,@CRUser,Getdate(),'0',@HosID) set @ID=@@IDENTITY print @ID insert into IN_DocQueueTB (DocQueueID,ShiftID,DoctorID,DocQueueState,CRUser,CRdate,Del,HosID) select @ID,ShiftID,DoctorID,DocQueueState,CRUser,CRdate,Del,HosID from IN_DocQueueTB where DocQueueID=@ShiftDateID set @timeCount=@ShiftDateTime fetch next from cursor1 into @ShiftDateID,@ShiftID,@ShiftDateTime,@ShiftDateState,@QueueID,@CRUser,@HosID end close cursor1 deallocate cursor1 END
本文标题:SQL 游标声明、操作、排班操作
本文链接:https://vtzw.com/post/606.html
版权声明:本文不使用任何协议授权,您可以任何形式自由转载或使用。
发表评论 / 取消回复