--增加分类 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 --删除旧记录 delete from SYS_Scripts where id=2101 --删除脚本内容 GO GO IF not EXISTS(SELECT * FROM SYS_Scripts WHERE id=2101) insert into SYS_Scripts(ID,CategoryID,Code,Name,Description,xType,DatasourceID,DisplayNames,xRowNum,xText,UpdateDate,UpdateUser,UpdateMode) Values(2101, 31, 'Sql_合理用药住院病人', '合理用药', '合理用药住院病人信息', 1, 0, Null, 1, 'declare @VAA07 int set @VAA07 = %d select a.VAE01 VAA07, b.VAA01,b.VAA05,a.VAE46 VAA10,b.VAA12,isnull(a.VAE19,1) FVisitId ,b.VAA04 VAA03 ,isnull(d.ABW02,''不详'') ABW02,'''' FWeight,'''' FHeight from VAE1 a join VAA1 b on a.VAA01 = b.VAA01 left join ABW1 d on b.ABW01 = d.ABW01 where (@VAA07 = 0 and Exists(select c.* from CBM2 c where c.ACF01 = 2 and a.VAE01 = c.VAA07 and c.CBM01 in (%s)) ) or (@VAA07 > 0 and a.VAE01 = @VAA07)', '2014-08-07 10:43:17', '(8058)高瑜', 0) else print 'SYS_Scripts.id=2101 已经存在.' GO