日期:2014-05-17 浏览次数:20642 次
USE [DP6_Siemens]
GO
/****** Object: StoredProcedure [dbo].[Siemens_Confirm_JH] Script Date: 04/09/2013 09:08:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[Siemens_Confirm_JH]
@BeginTime VARCHAR(10) ,
@EndTime VARCHAR(10) ,
@Corpid INT
AS
BEGIN
--建立一个临时表,用于存放每天计划任务的内容
CREATE TABLE #abc
(
a VARCHAR(MAX) ,
b VARCHAR(MAX) ,
c VARCHAR(MAX) ,
d INT
)
--循环,求这周JH任务的数量,提取每天编号
DECLARE @Commons INT ,
@index INT ,
@commonid INT ,
@memberid INT
SET @index = 1
SELECT @Commons = COUNT(DISTINCT a.CommonId)
FROM dbo.DP_CommonSmsEntries a
WHERE a.corpid = @Corpid
AND a.RecvTime >= @BeginTime
AND a.RecvTime < @EndTime
AND Instruction = 'JH'
CREATE TABLE #Commons
(
CommonId VARCHAR(50) ,
memberid INT
)
INSERT INTO #Commons
SELECT DISTINCT
CommonId ,
MemberId
FROM DP_CommonSmsEntries a
&nb