最新的防止复制的SQL代码,速度快!
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO dedecms.com
CREATE TRIGGER [dbo].[clear_copyitems] ON [dbo].[warehouse]
FOR UPDATE
AS
BEGIN
IF UPDATE(items)
BEGIN
DECLARE @al_acid varchar(10)
DECLARE @al_name varchar(10) dedecms.com
DECLARE @whItems AS binary(1200)
DECLARE @bdItems AS binary(760)
DECLARE @bItem AS binary(1)
DECLARE @wItem AS binary(1)
DECLARE @bItemId AS binary(4)
DECLARE @WItemId AS binary(4)
DECLARE @i AS int
DECLARE @ii AS int
DECLARE @find AS int
SET @find=0 dedecms.com
SELECT @al_acid=inserted.accountid,@whItems=inserted.items FROM inserted
SELECT @al_name=GameIDC FROM AccountCharacter WHERE id=@al_acid
SELECT @bdItems=inventory FROM character WHERE accountid=@al_acid AND name=@al_name
SET @i=0
WHILE @i<120
BEGIN
SET @wItem=SUBSTRING(@whItems,@i*10+1,1)
SET @wItemId=SUBSTRING(@whItems,@i*10+4,4)
IF @wItem<>0xFF AND @wItemId<>0x00000000 AND @wItem IS NOT NULL AND @wItemId IS NOT NULL
BEGIN
SET @ii=0
WHILE @ii<76
BEGIN
SET @bItem=SUBSTRING(@bdItems,@ii*10+1,1)
SET @bItemId=SUBSTRING(@bdItems,@ii*10+4,4)
IF @bItem<>0xFF AND @bItemId<>0x00000000
BEGIN
IF @bItem=@wItem AND @bItemId=@wItemId
BEGIN
SET @whitems=SUBSTRING(@whitems,1,@i*10)+0xFFFFFFFFFFFFFFFFFFFF+SUBSTRING(@whitems,(1+@i)*10+1,(76-1-@i)*10)
SET @find=1
SET @ii=76
END
SET @ii=@ii+1
END
END
SET @i=@i+1
END
END
IF @find=1
BEGIN
UPDATE warehouse SET items=@whitems WHERE accountid=@al_acid
END
END
END
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
dedecms.com