首页 > 代码库 > sql4

sql4

USE [MainDb]GO/****** Object:  StoredProcedure [dbo].[BackDataUpdate]    Script Date: 07/15/2014 08:46:25 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCreate PROCEDURE [dbo].[ProcChatOnlineByAddDateStatisticSelect](    @sDate VARCHAR(10),    @eDate VARCHAR(10) )ASBEGIN TRAN    DECLARE @ID AS INT    BEGIN TRY        SET @ID=0        SELECT TOP 1 @ID=ID FROM backdata WITH(NOLOCK) WHERE            ManagerID=@ManagerID AND CountDate=YEAR(GETDATE())*10000+MONTH(GETDATE())*100+DAY(GETDATE())        IF @ID=0            INSERT INTO backdata(ManagerID,CountDate) VALUES(                @ManagerID,YEAR(GETDATE())*10000+MONTH(GETDATE())*100+DAY(GETDATE())            )                IF @Pass=1                UPDATE backdata SET resume_pass=resume_pass + 1 WHERE                ManagerID=@ManagerID AND CountDate=YEAR(GETDATE())*10000+MONTH(GETDATE())*100+DAY(GETDATE())        IF @Pass=10            UPDATE backdata SET resume_nopass=resume_nopass + 1 WHERE                ManagerID=@ManagerID AND CountDate=YEAR(GETDATE())*10000+MONTH(GETDATE())*100+DAY(GETDATE())    END TRY    BEGIN CATCH        GOTO ERR    END CATCHCOMMIT TRANRETURN 1ERR:BEGIN    ROLLBACK TRAN    RETURN 0ENDGO