if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[up_DelHist_FWDH]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[up_DelHist_FWDH]
Go

create procedure up_DelHist_FWDH
@BeginDate varchar(10) ,
@EndDate varchar(10) 
With Encryption
as 


declare @sSql varchar(1000)

set @sSql='delete from FWDHB where FormNO in '+
'(select FormNo from FWDHH where CheckType=''3'' and WriteDate>='''+@BeginDate+''' and WriteDate<='''+@EndDate+''')'
exec(@sSql)

set @sSql='delete  from FWDHH where CheckType=''3'' and WriteDate>='''+@BeginDate+''' and WriteDate<='''+@EndDate+''''
exec(@sSql)

set @sSql='delete from FWDHB_history where FormNO in '+
'(select FormNo from FWDHH where CheckType=''3'' and WriteDate>='''+@BeginDate+''' and WriteDate<='''+@EndDate+''')'
exec(@sSql)

set @sSql='delete  from FWDHH_history where CheckType=''3'' and WriteDate>='''+@BeginDate+''' and WriteDate<='''+@EndDate+''''
exec(@sSql)