[导入]sp_KinCount
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Sp_KinCount]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[Sp_KinCount]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS OFF
GO
Create PROCEDURE [dbo].[Sp_KinCount]
@Count_Channel varchar(50),
@Count_Level varchar(50),
@Count_Category varchar(50),
@Count_EditName varchar(50)
WITH ENCRYPTION
AS
IF (ISNUMERIC(@Count_Level) = 0) SET @Count_Level = 0
SET @Count_Level = ROUND(@Count_Level, 0)
IF (@Count_Level > 3) SET @Count_Level = 1
SET @Count_Channel = ISNULL(@Count_Channel,'')
IF (@Count_Channel = '')
BEGIN
SET @Count_Channel = '首页'
SET @Count_Level = 1
SET @Count_EditName = ''
END
SET @Count_Category = ISNULL(@Count_Category,'')
IF NOT EXISTS (Select TOP 1 '1' FROM t_Administrator Where UserName = @Count_EditName)
BEGIN
IF NOT EXISTS
(
Select TOP 1 '1'
FROM Kin_Count
Where DateDiff(DAY, Count_Date, GETDATE()) = 0
AND Count_Category = @Count_Category
AND Count_EditName = '离职编辑'
AND Count_Channel = @Count_Channel
AND Count_Level = @Count_Level
)
BEGIN
Insert INTO Kin_Count(Count_Channel, Count_Level, Count_Category, Count_EditName)
VALUES (@Count_Channel, @Count_Level, @Count_Category, '离职编辑')
END
ELSE
BEGIN
Update Kin_Count
SET Count_Counter = Count_Counter + 1
Where Count_Category = @Count_Category
AND DateDiff(DAY, Count_Date, GETDATE()) = 0
AND Count_EditName = '离职编辑'
AND Count_Channel = @Count_Channel
AND Count_Level = @Count_Level
END
END
ELSE
BEGIN
IF NOT EXISTS
(
Select TOP 1 '1'
FROM Kin_Count
Where DateDiff(DAY, Count_Date, GETDATE()) = 0
AND Count_Category = @Count_Category
AND Count_EditName = @Count_EditName
AND Count_Channel = @Count_Channel
AND Count_Level = @Count_Level
)
BEGIN
Insert INTO Kin_Count(Count_Channel, Count_Level, Count_Category, Count_EditName)
VALUES (@Count_Channel, @Count_Level, @Count_Category, @Count_EditName)
END
ELSE
BEGIN
Update Kin_Count
SET Count_Counter = Count_Counter + 1
Where Count_Category = @Count_Category
AND DateDiff(DAY, Count_Date, GETDATE()) = 0
AND Count_EditName = @Count_EditName
AND Count_Channel = @Count_Channel
AND Count_Level = @Count_Level
END
END
/*
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Kin_Count]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
Create TABLE [dbo].[Kin_Count] (
[Count_ID] [int] IDENTITY (1, 1) NOT NULL ,
[Count_Date] [smalldatetime] NOT NULL ,
[Count_Channel] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[Count_Level] [tinyint] NOT NULL ,
[Count_Category] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Count_EditName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[Count_Counter] [int] NOT NULL
) ON [PRIMARY]
--GO
*/
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
--Exec Sp_KinCount '资讯','1','男装新闻','Jorkin'
文章来源:http://Jorkin.Reallydo.Com/default.asp?id=456

浙公网安备 33010602011771号