declare @resultCount numeric(10);
declare @sql1 nvarchar(2000);
declare @sql2 nvarchar(2000);
select @resultCount=count(0) from sysobjects so join syscolumns sc on so.id=sc.id
where so.xtype='u' and so.name='Sterilizer' and sc.name='needNoticeSterilisation';
if @resultCount >= 1 begin
	set @sql1 = 'insert into SterilizationFrequecyRemind (frequency, remindMode, sterilisation_id, sterilizer_id) select 1, ''非强制提醒'', ss.id, s.id from sterilizer s join sterilisation ss on s.needNoticeSterilisation = ss.sterilisation where s.needNoticeSterilisation is not null and s.needNoticeSterilisation <> ''''';
	set @sql2 = 'update Sterilizer set needNoticeSterilisation = null where needNoticeSterilisation is not null';
	execute sp_executesql @sql1;
	execute sp_executesql @sql2;
end;