--增加分类 GO IF not EXISTS(SELECT * FROM SYS_ScriptCategories WHERE id=31) insert into SYS_ScriptCategories(ID,Code,Name,ComponentID,xRowNum,ParentID,xLevel,Description) Values(31, 'SC31', '临床医护管理', 17, 0, 0, 0, Null) else print 'SYS_ScriptCategories.id=31 已经存在.' GO If EXISTS(SELECT * from Sys_CustomScripts WHERE ID = 31) Update a SET a.Custom = b.Custom from SYS_Scripts a join Sys_CustomScripts b on b.ID = a.ID where a.ID=31 GO --删除旧记录 delete from SYS_Scripts where id=16993 --删除脚本内容 GO GO IF not EXISTS(SELECT * FROM SYS_Scripts WHERE id=16993) insert into SYS_Scripts(ID,CategoryID,Code,Name,Description,xType,DatasourceID,DisplayNames,xRowNum,xText,UpdateDate,UpdateUser,UpdateMode,Custom) Values(16993, 195, 'SQL_诊断树形', 'SQL_诊断树形', 'SQL_诊断树形', 1, 0, Null, 1, 'SELECT BAH01,BAH03,BAH01A FROM BAH1 with(nolock) where BAH07 in (%s)', '2019-11-15 15:10:59', '(0069)付枫', 0, 0) else print 'SYS_Scripts.id=16993 已经存在.' GO If EXISTS(SELECT * from Sys_CustomScripts WHERE ID = 16993) Update a SET a.Custom = b.Custom from SYS_Scripts a join Sys_CustomScripts b on b.ID = a.ID where a.ID=16993 GO --增加分类 GO IF not EXISTS(SELECT * FROM SYS_ScriptCategories WHERE id=31) insert into SYS_ScriptCategories(ID,Code,Name,ComponentID,xRowNum,ParentID,xLevel,Description) Values(31, 'SC31', '临床医护管理', 17, 0, 0, 0, Null) else print 'SYS_ScriptCategories.id=31 已经存在.' GO If EXISTS(SELECT * from Sys_CustomScripts WHERE ID = 31) Update a SET a.Custom = b.Custom from SYS_Scripts a join Sys_CustomScripts b on b.ID = a.ID where a.ID=31 GO --删除旧记录 delete from SYS_Scripts where id=16994 --删除脚本内容 GO GO IF not EXISTS(SELECT * FROM SYS_Scripts WHERE id=16994) insert into SYS_Scripts(ID,CategoryID,Code,Name,Description,xType,DatasourceID,DisplayNames,xRowNum,xText,UpdateDate,UpdateUser,UpdateMode,Custom) Values(16994, 195, 'SQL_诊断树形查询', 'SQL_诊断树形查询', 'SQL_诊断树形查询', 1, 0, '', 1, 'DECLARE @bdate datetime declare @BAK18 varchar(64) set @BAK18=''0'' if exists(select BLP01 from BLP1 where BLP02 = 238) begin select @BAK18=BLP03 from BLP1 with(nolock) where BLP02=238 end set @bdate = Getdate() SELECT a.BAK01,a.BAK02,a.BAK05,a.ABBRP,a.ABBRW,a.ABW01,isnull(b.CAM01,0)AS CAM01,a.ABX01,d.BNO03,d.BNO04 FROM BAK1 a with(nolock) LEFT JOIN BEA1 b with(nolock) ON a.BAK01 = b.BAK01 left join BNO1 d with(nolock) on d.BAK02=a.BAK02 WHERE a.BAF01 in (%s) and bak17>@bdate and a.BAH01=%s and ((isnull(a.BAK18,'''')=isnull(@BAK18,'''') and @BAK18<>''0'' ) or @BAK18=''0'' ) and ((a.BAK22=0)or(a.BAK22=1 and exists(select * from BOZ1 e with(nolock) where e.BAK01=a.BAK01 and e.BCK01=%d) ) )', '2019-11-15 15:11:15', '(0069)付枫', 0, 0) else print 'SYS_Scripts.id=16994 已经存在.' GO If EXISTS(SELECT * from Sys_CustomScripts WHERE ID = 16994) Update a SET a.Custom = b.Custom from SYS_Scripts a join Sys_CustomScripts b on b.ID = a.ID where a.ID=16994 GO --增加分类 GO IF not EXISTS(SELECT * FROM SYS_ScriptCategories WHERE id=31) insert into SYS_ScriptCategories(ID,Code,Name,ComponentID,xRowNum,ParentID,xLevel,Description) Values(31, 'SC31', '临床医护管理', 17, 0, 0, 0, Null) else print 'SYS_ScriptCategories.id=31 已经存在.' GO If EXISTS(SELECT * from Sys_CustomScripts WHERE ID = 31) Update a SET a.Custom = b.Custom from SYS_Scripts a join Sys_CustomScripts b on b.ID = a.ID where a.ID=31 GO --删除旧记录 delete from SYS_Scripts where id=17000 --删除脚本内容 GO GO IF not EXISTS(SELECT * FROM SYS_Scripts WHERE id=17000) insert into SYS_Scripts(ID,CategoryID,Code,Name,Description,xType,DatasourceID,DisplayNames,xRowNum,xText,UpdateDate,UpdateUser,UpdateMode,Custom) Values(17000, 195, 'Sql_诊断树形搜索', 'Sql_诊断树形搜索', 'Sql_诊断树形搜索', 1, 0, Null, 1, 'DECLARE @lTxt varchar(100),@bdate datetime,@bck01 int declare @BAK18 varchar(64) set @BAK18=''0'' if exists(select BLP01 from BLP1 where BLP02 = 238) begin select @BAK18=BLP03 from BLP1 with(nolock) where BLP02=238 end SET @lTxt = %s set @bck01=%d set @bdate = Getdate() SELECT a.BAK01,a.BAK02,a.BAK05,a.BAK06,a.ABBRP,a.ABBRW,a.ABW01,isnull(b.CAM01,0)AS CAM01,a.ABX01,d.BNO03,d.BNO04 FROM BAK1 a with(nolock) LEFT JOIN BEA1 b with(nolock) ON a.BAK01 = b.BAK01 left join BNO1 d with(nolock) on d.BAK02=a.BAK02 WHERE a.BAF01 in (%s) and a.bak17>@bdate and ((a.BAK22=0)or(a.BAK22=1 and exists(select * from BOZ1 e with(nolock) where e.BAK01=a.BAK01 and e.BCK01=@bck01) ) ) and (a.BAK02 LIKE @lTxt OR a.BAK05 LIKE @lTxt OR a.BAK06 LIKE @lTxt OR a.ABBRP LIKE @lTxt OR a.ABBRW LIKE @lTxt) and ((isnull(a.BAK18,'''')=isnull(@BAK18,'''') and @BAK18<>''0'' ) or @BAK18=''0'' )', '2019-11-15 15:38:57', '(0069)付枫', 0, 0) else print 'SYS_Scripts.id=17000 已经存在.' GO If EXISTS(SELECT * from Sys_CustomScripts WHERE ID = 17000) Update a SET a.Custom = b.Custom from SYS_Scripts a join Sys_CustomScripts b on b.ID = a.ID where a.ID=17000 GO