Code
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
create procedure getPercent
AS
declare @CpyID int
declare Cpycursor cursor for
select fld_id from User_Crunode.T_CompanyInfo
open Cpycursor
fetch next from Cpycursor into @CpyID
while @@FETCH_STATUS=0
begin
----start
declare @FirstChar varchar(50)
declare @FirstPoint int
declare @lenth int
declare @Condition nvarchar(1000)
begin
declare @AllChar varchar(100)
--set @AllChar='11,444,93,2,1'
--set @CpyID=10
select @AllChar=fld_KeyWords from T_SpiderSettings where fld_CpyID=@CpyID and fld_Remark like '%评%'
set @lenth=len(@AllChar)
create table #Temp_String
(FID int identity,
Content varchar(50))
set @FirstPoint=charindex( ',',@AllChar)
while( @FirstPoint> 0)
begin
set @FirstChar=substring(@AllChar,0,@FirstPoint)
insert into #Temp_String(Content) values (@FirstChar)
set @AllChar=substring(@AllChar,@FirstPoint+1,@lenth)
set @FirstPoint=charindex( ',',@AllChar)
end
insert into #Temp_String(Content) values (@AllChar)
declare mycursor cursor for
select Content from #Temp_String
declare @value varchar(50)
open mycursor
fetch next from mycursor into @value
while @@FETCH_STATUS=0
begin
if len(@Condition)<=0 or @Condition is null
begin
set @Condition='fld_keywordsFound like '''+@value+''''
end
else
begin
set @Condition=@Condition+' or fld_keywordsFound like '''+@value+''''
end
fetch next from mycursor into @value
end
end
declare @ConditionTotal nvarchar(1000)
set @ConditionTotal='select @p=count(*) from T_spiderReports where (datepart(month,getdate()))=datepart(month,fld_datetime)
and (datepart(day,getdate()))=datepart(day,fld_datetime) and (datepart(year,getdate()))=datepart(year,fld_datetime) and fld_cpyID= '+str(@CpyID)
declare @CurrentNumTotal int
execute sp_executeSql @ConditionTotal,N'@p int output',@CurrentNumTotal output
if @CurrentNumTotal is null or len(@CurrentNumTotal)<=0
set @CurrentNumTotal=0
--print @CurrentNumTotal
declare @ConditionTotalBad nvarchar(1000)
set @ConditionTotalBad='select @p=count(*) from T_spiderReports where (datepart(month,getdate()))=datepart(month,fld_datetime) and (datepart(day,getdate()))=datepart(day,fld_datetime) and (datepart(year,getdate()))=datepart(year,fld_datetime) and fld_cpyID= '+str(@CpyID)+' and ('+@Condition+')'
--print @ConditionTotalBad
declare @CurrentNumTotalBad int
execute sp_executeSql @ConditionTotalBad,N'@p int output',@CurrentNumTotalBad output
if @CurrentNumTotalBad is null or len(@CurrentNumTotalBad)<=0
set @CurrentNumTotalBad=0
insert into t_ResultTotal ([fld_Total],[fld_BadTotal],[fld_CpyID]) values (@CurrentNumTotal,@CurrentNumTotalBad,@CpyID)
--print @CurrentNumTotalBad
drop table #Temp_String
close mycursor
DEALLOCATE mycursor
--end
fetch next from Cpycursor into @CpyID
end
close Cpycursor
DEALLOCATE Cpycursor
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
create procedure getPercent
AS
declare @CpyID int
declare Cpycursor cursor for
select fld_id from User_Crunode.T_CompanyInfo
open Cpycursor
fetch next from Cpycursor into @CpyID
while @@FETCH_STATUS=0
begin
----start
declare @FirstChar varchar(50)
declare @FirstPoint int
declare @lenth int
declare @Condition nvarchar(1000)
begin
declare @AllChar varchar(100)
--set @AllChar='11,444,93,2,1'
--set @CpyID=10
select @AllChar=fld_KeyWords from T_SpiderSettings where fld_CpyID=@CpyID and fld_Remark like '%评%'
set @lenth=len(@AllChar)
create table #Temp_String
(FID int identity,
Content varchar(50))
set @FirstPoint=charindex( ',',@AllChar)
while( @FirstPoint> 0)
begin
set @FirstChar=substring(@AllChar,0,@FirstPoint)
insert into #Temp_String(Content) values (@FirstChar)
set @AllChar=substring(@AllChar,@FirstPoint+1,@lenth)
set @FirstPoint=charindex( ',',@AllChar)
end
insert into #Temp_String(Content) values (@AllChar)
declare mycursor cursor for
select Content from #Temp_String
declare @value varchar(50)
open mycursor
fetch next from mycursor into @value
while @@FETCH_STATUS=0
begin
if len(@Condition)<=0 or @Condition is null
begin
set @Condition='fld_keywordsFound like '''+@value+''''
end
else
begin
set @Condition=@Condition+' or fld_keywordsFound like '''+@value+''''
end
fetch next from mycursor into @value
end
end
declare @ConditionTotal nvarchar(1000)
set @ConditionTotal='select @p=count(*) from T_spiderReports where (datepart(month,getdate()))=datepart(month,fld_datetime)
and (datepart(day,getdate()))=datepart(day,fld_datetime) and (datepart(year,getdate()))=datepart(year,fld_datetime) and fld_cpyID= '+str(@CpyID)
declare @CurrentNumTotal int
execute sp_executeSql @ConditionTotal,N'@p int output',@CurrentNumTotal output
if @CurrentNumTotal is null or len(@CurrentNumTotal)<=0
set @CurrentNumTotal=0
--print @CurrentNumTotal
declare @ConditionTotalBad nvarchar(1000)
set @ConditionTotalBad='select @p=count(*) from T_spiderReports where (datepart(month,getdate()))=datepart(month,fld_datetime) and (datepart(day,getdate()))=datepart(day,fld_datetime) and (datepart(year,getdate()))=datepart(year,fld_datetime) and fld_cpyID= '+str(@CpyID)+' and ('+@Condition+')'
--print @ConditionTotalBad
declare @CurrentNumTotalBad int
execute sp_executeSql @ConditionTotalBad,N'@p int output',@CurrentNumTotalBad output
if @CurrentNumTotalBad is null or len(@CurrentNumTotalBad)<=0
set @CurrentNumTotalBad=0
insert into t_ResultTotal ([fld_Total],[fld_BadTotal],[fld_CpyID]) values (@CurrentNumTotal,@CurrentNumTotalBad,@CpyID)
--print @CurrentNumTotalBad
drop table #Temp_String
close mycursor
DEALLOCATE mycursor
--end
fetch next from Cpycursor into @CpyID
end
close Cpycursor
DEALLOCATE Cpycursor
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO