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

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


declare @sSql varchar(8000)

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

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

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

