ANSI_NULLS を ON に設定
QUOTED_IDENTIFIER を ON に設定
go
-- ================================== ===========
-- 著者:wgh
-- 作成日: 2012-06-07
-- 説明: IP アクセスの事前統計
-- ===== = =======================================
CREATE PROCEDURE [dbo].[PROC_HB_PreStatByIP] ]
@BeginTime varchar(50),
@EndTime varchar(50),
@TimeType int、--0 は時間を表し、1 は日を表します
@ChannelID varchar(10)='0',
@ I pAddress varchar(20)
AS
BEGIN
宣言 @sql1 nvarchar(2000)
IF @TimeType = 0
BEGIN
SET @sql1='SELECT CONVERT(varchar(13),AddTime ,120) AS 'Date''
、ChannelID AS ''プロモーション チャンネル''
、IPAddress AS ''IP アドレス''
、ViewCount AS ''閲覧数''
、 ClickCount AS ''クリック数''
FROM dbo.HB_AdPreStatIP WHERE AddTime>=''+@BeginTime+'''' AND AddTime<=''+@EndTIME+''''
=@sql1 1 + ' AND ChannelID='''+@ChannelID+''''
1 +' AND IPAddress=' ''+@IpAddress+''''
END
SET @sql1 =@sql1+' ORDER BY ViewCount DESC' END
'SELECT CONVERT(varchar(10), AddTime,120) AS ''日付''
、ChannelID AS ''プロモーション チャンネル''
、IPAddress AS ''IP アドレス''
、 、SUM (ViewCount) '' views's's's's sum(viewcount)(clickCount)(clickCount)として「クリック数」 ' - −-- - – − ‐ ‐ ‐ - dbo.hb_adprestatip +' AND IPAddress='''+@IpAddress+''''
END
SET @sql1 =@sql1 + 'GROUP BY CONVERT(varchar(10),AddTime,120),ChannelID,IPAddress ORDER BY SUM(ViewCount) ) DESC'
END
EXEC sp_executesql @sql1
END