--增加分类 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=1166 --删除脚本内容 GO GO IF not EXISTS(SELECT * FROM SYS_Scripts WHERE id=1166) insert into SYS_Scripts(ID,CategoryID,Code,Name,Description,xType,DatasourceID,DisplayNames,xRowNum,xText,UpdateDate,UpdateUser,UpdateMode,Custom) Values(1166, 47, 'SQL_PatFindCon', Null, '查找病人条件', 1, 1, Null, 1, 'Select ''按住院号'' as FTerm, ''VAA04'' as FFeildName union all Select ''按姓名'', ''VAA05'' union all Select ''按就诊号'', ''VAA03'' union all Select ''按身份证'', ''VAA15'' ', '2018-07-08 18:03:45', '(8088)王海涛', 0, 0) else print 'SYS_Scripts.id=1166 已经存在.' GO If EXISTS(SELECT * from Sys_CustomScripts WHERE ID = 1166) Update a SET a.Custom = b.Custom from SYS_Scripts a join Sys_CustomScripts b on b.ID = a.ID where a.ID=1166 GO