 --系统启动是先建表再执行sql文件的升级 
IF OBJECT_ID('RinserDepartment', 'U') is null
BEGIN  
	--所以一般情况下是不会进这里的。
	select r.id rinserId,(select max(id) from OrgUnit ou where ou.orgUnitCoding=r.orgUnitCoding ) orgUnitId
	into RinserDepartment
	from Rinser r
END 
else if not EXISTS (SELECT 1 FROM RinserDepartment) 
BEGIN  
    insert into RinserDepartment(rinserId,orgUnitId) 
	select r.id rinserId,(select max(id) from OrgUnit ou where ou.orgUnitCoding=r.orgUnitCoding ) orgUnitId
	from Rinser r
END;