Сложете тази процедура в Query Analyzera
с тази процедура ще предотвратите спиранията през Guild
Code:
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[WZ_GuildCreate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[WZ_GuildCreate]
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
CREATE procedure WZ_GuildCreate
@GuildName nvarchar(8),
@MasterName nvarchar(10)
as
if PatIndex('%[^0-9A-Z]%',@GuildName) > 0
BEGIN
Set nocount off
END
ELSE
BEGIN
if (SELECT COUNT(*) FROM Guild where G_Name=@GuildName)=0
BEGIN
DECLARE @ErrorCode int
SET @ErrorCode = 0
SET XACT_ABORT OFF
Set nocount on
begin transaction
INSERT INTO Guild (G_Name,G_Master,G_Score,G_Register) valueS (@GuildName, @MasterName, 0, getdate())
IF ( @@Error <> 0 )
BEGIN
SET @ErrorCode = 1
END
IF ( @ErrorCode = 0 )
BEGIN
INSERT GuildMember (Name, G_Name, G_Level) valueS (@MasterName, @GuildName, 1)
IF ( @@Error <> 0 )
BEGIN
SET @ErrorCode = 2
END
END
IF ( @ErrorCode <> 0 )
rollback transaction
ELSE
commit transaction
select @ErrorCode
Set nocount off
SET XACT_ABORT ON
END
END
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
с тази процедура ще предотвратите спиранията през Guild