Ningun Source amigo. Yo en su momento tambien renegue con esto, y encontre la solucion..
Te paso dos querys, se que una es la que lo arregla , pero no me acuerdo bien cual es.
USE MuOnline
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[T_PeriodItem_Data]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[T_PeriodItem_Data]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[T_CashShop_LOG]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[T_CashShop_LOG]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[WZ_PeriodItemDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[WZ_PeriodItemDelete]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[WZ_PeriodItemInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[WZ_PeriodItemInsert]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[WZ_PeriodItemSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[WZ_PeriodItemSelect]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[WZ_PeriodItemUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[WZ_PeriodItemUpdate]
GO
CREATE TABLE [dbo].[T_PeriodItem_Data](
[memb_guid] [int] NOT NULL,
[memb__char] [varchar](10) NOT NULL,
[ItemCode] [int] NOT NULL,
[ItemEffect1] [int] NOT NULL,
[ItemEffect2] [int] NOT NULL,
[UseTime] [int] NOT NULL,
[ExpireDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [T_CashShop_LOG] (
[AccountID] [varchar] (10) NULL ,
[Character] [varchar] (10) NULL ,
[ItemType] [int] NULL ,
[ItemIndex] [int] NULL ,
[Level] [int] NULL ,
[Skill] [int] NULL ,
[Luck] [int] NULL ,
[JoL] [int] NULL ,
[ExcOp] [int] NULL ,
[Dur] [int] NULL ,
[Serial] [varchar] (8) NULL ,
[DateBuy] [char] (10) NULL ,
[TimeBuy] [char] (8) NULL
) ON [PRIMARY]
GO
SET NOCOUNT OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO
CREATE PROCEDURE [dbo].[WZ_PeriodItemDelete]
@memb_guid int,
@memb__char varchar(10)
AS
BEGIN
SET NOCOUNT ON
Declare @Result int
Set @Result = 1
Begin Transaction
DELETE FROM T_PeriodItem_Data WHERE memb__char = @memb__char and memb_guid = @memb_guid
If @@Error <> 0
begin
Set @Result = 0
CREATE TABLE [T_PeriodItemInfo] (
[PeriodIndex] [int] IDENTITY (1, 1) NOT NULL ,
[UserGuid] [int] NOT NULL ,
[CharacterName] [char] (10) COLLATE Korean_Wansung_CI_AS NOT NULL ,
[ItemCode] [int] NOT NULL ,
[EffectType1] [tinyint] NOT NULL ,
[EffectType2] [tinyint] NULL ,
[UsedTime] [int] NOT NULL CONSTRAINT [DF_T_PeriodItemInfo_UsedTime] DEFAULT (0),
[LeftTime] [int] NOT NULL ,
[BuyDate] [smalldatetime] NOT NULL ,
[ExpireDate] [smalldatetime] NOT NULL ,
[UsedInfo] [tinyint] NOT NULL CONSTRAINT [DF_T_PeriodItemInfo_UsedInfo] DEFAULT (0),
[OptionType] [tinyint] NOT NULL CONSTRAINT [DF_T_PeriodItemInfo_OptionType] DEFAULT (2)
) ON [PRIMARY]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE dbo.WZ_PeriodItemDelete
@UserGuid int,
@CharacterName varchar(10)
AS BEGIN
DECLARE @ErrorCode int
DECLARE @ItemInfoCount int
SET @ErrorCode = 0
SET @ItemInfoCount = 0
SET nocount on
SELECT @ItemInfoCount = COUNT(*) FROM T_PeriodItemInfo where UserGuid = @UserGuid AND CharacterName = @CharacterName
IF( @ItemInfoCount < 1 )
BEGIN
SET @ErrorCode = 1
END
IF( @ErrorCode <> 1 )
BEGIN
UPDATE T_PeriodItemInfo SET UsedInfo = 0 WHERE UserGuid = @UserGuid AND CharacterName = @CharacterName
END
SELECT @ErrorCode
SET nocount off
END
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE procedure dbo.WZ_PeriodItemInsert
@UserGuid int,
@CharacterName varchar(10),
@ItemCode int,
@OptionType tinyint,
@EffectType1 tinyint,
@EffectType2 tinyint,
@TotalUsePeriod int,
@ExpireDate varchar(20)
as
BEGIN
DECLARE @ErrorCode int
DECLARE @PeriodItemIndex int
SET @ErrorCode = 0
SET @PeriodItemIndex = 0
SET XACT_ABORT ON
Set nocount on
begin transaction
-- OptionType? ?? ???? ???? ??? ????.
SELECT @PeriodItemIndex = PeriodIndex FROM T_PeriodItemInfo WHERE UserGuid = @UserGuid AND CharacterName = @CharacterName AND OptionType = @OptionType AND UsedInfo = 1
IF ( @PeriodItemIndex != 0 )
BEGIN
UPDATE T_PeriodItemInfo SET UsedInfo = 0 WHERE UserGuid = @UserGuid AND CharacterName = @CharacterName AND OptionType = @OptionType AND UsedInfo = 1
END
INSERT INTO T_PeriodItemInfo (UserGuid, CharacterName, ItemCode, OptionType, EffectType1, EffectType2, LeftTime, BuyDate, ExpireDate, UsedInfo) VALUES
( @UserGuid, @CharacterName, @ItemCode, @OptionType, @EffectType1, @EffectType2, @TotalUsePeriod, GETDATE(), @ExpireDate, 1 )
IF( @@Error <> 0 )
BEGIN
SET @ErrorCode = 2
END
IF ( @ErrorCode <> 0 )
rollback transaction
ELSE
commit transaction
SELECT @ErrorCode
Set nocount off
SET XACT_ABORT OFF
END
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE procedure dbo.WZ_PeriodItemSelect
@UserGuid int,
@CharacterName varchar(10)
as
BEGIN
DECLARE @ErrorCode int
DECLARE @ItemInfoCount int
DECLARE @PeriodIndex int
DECLARE @ExpireDate smalldatetime
DECLARE @UsedInfo tinyint
SET @PeriodIndex = 0
SET @ErrorCode = 0
SET @ItemInfoCount = 0
SET @UsedInfo = 0
Set nocount on
-- ?? ??? ?? ???? ??? ?? ???.
DECLARE CUR CURSOR FOR SELECT [PeriodIndex], [ExpireDate], [UsedInfo] FROM T_PeriodItemInfo WHERE UserGuid = @UserGuid AND CharacterName = @CharacterName AND UsedInfo = 1 FOR UPDATE
OPEN CUR
FETCH NEXT FROM CUR INTO @PeriodIndex, @ExpireDate, @UsedInfo
WHILE( @@fetch_status <> -1 )
BEGIN
IF( @@fetch_status <> -2 )
BEGIN
IF( @ExpireDate < GetDate() )
BEGIN
UPDATE T_PeriodItemInfo SET UsedInfo = 0 WHERE PeriodIndex = @PeriodIndex
END
END
FETCH NEXT FROM CUR INTO @PeriodIndex, @ExpireDate, @UsedInfo
END
-- ??? ?? ??? ?? ???? ??????.
SELECT *, DATEDIFF( minute, BuyDate, GETDATE() ) AS UsedMinutes, DATEDIFF( minute, GETDATE(), ExpireDate ) AS LeftMinutes FROM T_PeriodItemInfo where UserGuid = @UserGuid AND CharacterName = @CharacterName AND UsedInfo = 1
--SELECT * FROM T_PeriodItemInfo where UserGuid = @UserGuid AND CharacterName = @CharacterName AND UsedInfo = 1
IF( @@Error <> 0 )
BEGIN
SET @ErrorCode = -1
END
CLOSE CUR
DEALLOCATE CUR
Set nocount off
END
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE procedure dbo.WZ_PeriodItemUpdate
@UserGuid int,
@CharacterName varchar(10),
@ItemCode int,
@UsedTime int,
@LeftTime int
as
BEGIN
DECLARE @ErrorCode int
DECLARE @ItemInfoCount int
DECLARE @RetLeftTime int
SET @ErrorCode = 0
SET @ItemInfoCount = 0
SET @RetLeftTime = 0
SET XACT_ABORT ON
Set nocount on
begin transaction
SELECT @ItemInfoCount = COUNT(*) FROM T_PeriodItemInfo where UserGuid = @UserGuid AND CharacterName = @CharacterName AND UsedInfo = 1
IF( @ItemInfoCount <> 1 )
BEGIN
SET @ErrorCode = 1
END
ELSE
BEGIN
UPDATE T_PeriodItemInfo SET UsedTime = UsedTime + @UsedTime, LeftTime = @LeftTime WHERE UserGuid = @UserGuid AND CharacterName = @CharacterName AND ItemCode = @ItemCode AND UsedInfo = 1
IF( @@Error <> 0 )
BEGIN
SET @ErrorCode = 2
END
END
SELECT @RetLeftTime = LeftTime FROM T_PeriodItemInfo where UserGuid = @UserGuid AND CharacterName = @CharacterName AND ItemCode = @ItemCode AND UsedInfo = 1
IF ( @RetLeftTime <= 0 )
BEGIN
UPDATE T_PeriodItemInfo SET UsedInfo = 0, LeftTime = 0 WHERE UserGuid = @UserGuid AND CharacterName = @CharacterName AND ItemCode = @ItemCode AND UsedInfo = 1
SET @ErrorCode = 3
END
IF ( @ErrorCode <> 0 AND @ErrorCode <> 3 )
rollback transaction
ELSE
commit transaction
select @ErrorCode
Set nocount off
SET XACT_ABORT OFF
END
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
[code]
salu8