--增加分类 GO IF not EXISTS(SELECT * FROM SYS_ScriptCategories WHERE id=1) insert into SYS_ScriptCategories(ID,Code,Name,ComponentID,xRowNum,ParentID,xLevel,Description) Values(1, 'SC1', 'HOMaster 基础管理', 1, 0, 0, 0, Null) else print 'SYS_ScriptCategories.id=1 已经存在.' GO If EXISTS(SELECT * from Sys_CustomScripts WHERE ID = 1) Update a SET a.Custom = b.Custom from SYS_Scripts a join Sys_CustomScripts b on b.ID = a.ID where a.ID=1 GO --删除旧记录 delete from SYS_Scripts where id=7786 --删除脚本内容 GO GO IF not EXISTS(SELECT * FROM SYS_Scripts WHERE id=7786) insert into SYS_Scripts(ID,CategoryID,Code,Name,Description,xType,DatasourceID,DisplayNames,xRowNum,xText,UpdateDate,UpdateUser,UpdateMode,Custom) Values(7786, 33, 'Sql_出院下达出院诊断', '', '出院下达出院诊断', 1, 1, Null, 1, 'declare @vao10 tinyint,@VAA07 int set @VAA07=%d set @vao10=%d if exists(select VAO01 from VAO2 where ACF01=2 and VAA07 = @VAA07 and VAO10=@vao10 and VAO11=3) select a.VAO25,a.VAO15,b.BAK02,a.VAO24,a.ABX01,a.BAK01A,a.CAM01,a.VAO18,a.IAD01,a.IAD03,a.IAD04 from VAO2 a with(nolock) left join BAK1 b with(nolock) on b.BAK01 = a.BAK01A where a.ACF01=2 and a.VAA07 = @VAA07 and a.VAO11=3 and a.VAF01=0 and (@vao10=3 or (@vao10<>3 and a.VAO10=@vao10)) order by a.VAO10,a.vao25,a.VAO06 else select a.VAO25,a.VAO15,b.BAK02,a.VAO24,a.ABX01,a.BAK01A,a.CAM01,a.VAO18,a.IAD01,a.IAD03,a.IAD04 from VAO2 a with(nolock) left join BAK1 b with(nolock) on b.BAK01 = a.BAK01A where a.ACF01=3 and a.VAA07 = @VAA07 and a.VAO11=3 and a.VAF01=0 and (@vao10=3 or (@vao10<>3 and a.VAO10=@vao10)) order by a.VAO10,a.vao25,a.VAO06 ', '2019-01-23 16:29:31', '(8058)高瑜', 0, 0) else print 'SYS_Scripts.id=7786 已经存在.' GO If EXISTS(SELECT * from Sys_CustomScripts WHERE ID = 7786) Update a SET a.Custom = b.Custom from SYS_Scripts a join Sys_CustomScripts b on b.ID = a.ID where a.ID=7786 GO