/****** Object: Table [dbo].[t_code_source] Script Date: 2021-09-30 8:27:17 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[t_code_filetype]( [代码] [varchar](2) NOT NULL, [文件类型] [varchar](8) NOT NULL, [是否必须] [bit] NULL, CONSTRAINT [PK_t_code_filetype] PRIMARY KEY CLUSTERED ( [代码] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO insert t_sys_code(权限代码,一级模块,二级模块,权限名称) values(617,'海运业务管理','海运业务管理','修改电子档案') insert t_sys_code_emp (权限代码,一级模块,二级模块,权限名称,人员,是否可操作) select 617,'海运业务管理','海运业务管理','修改电子档案',姓名,0 from t_sys_employee declare @vs_DocType varchar(50) declare CurPlu cursor for select 文件类型 from t_code_filetype where 是否必须=1 open CurPlu fetch next from CurPlu into @vs_DocType while @@Fetch_Status=0 begin update t_op_seae set 扣单状态='扣单' from t_op_seae b where datediff(day,b.开船日期,getdate())=7 and not EXISTS (select 1 from Receipt_Doc d where d.bsno=b.编号 and RECEIPTTYPE=@vs_DocType) fetch next from CurPlu into @vs_DocType end close CurPlu dealLocate CurPlu