Simple query for union limit

06/14/2014 16:05 $Apollo#1
;Hello epvp.
I thought would work for you, because I share it with you

Code:
USE [SRO_VT_SHARD]

GO
/****** Object:  StoredProcedure [dbo].[_Guild_Create]    Script Date: 14.06.2014 16:53:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO




--
ALTER PROCEDURE [dbo].[_Guild_Create]
    @guildName    varchar(64),
    @CreaterID    int
as
    if (exists (select id from _Guild where Name = @guildName))
    begin
        return -1000
    end
    if (exists (select CharID from _GuildMember where CharID = @CreaterID))
    begin
        return -1001
    end
begin transaction
    
    declare @guildID    int
    declare @FoundationDate  smalldatetime
    
    set @FoundationDate = GetDate()
    insert _Guild(Name, Lvl, GatheredSP, FoundationDate,Alliance,Booty) values @guildName+'_ULimit_1', 1, 0, @FoundationDate,0,0)
    insert _Guild(Name, Lvl, GatheredSP, FoundationDate,Alliance,Booty) values @guildName+'_ULimit_2', 1, 0, @FoundationDate,0,0)
    insert _Guild(Name, Lvl, GatheredSP, FoundationDate,Alliance,Booty) values @guildName+'_ULimit_3', 1, 0, @FoundationDate,0,0)
    insert _Guild(Name, Lvl, GatheredSP, FoundationDate,Alliance,Booty) values @guildName+'_ULimit_4', 1, 0, @FoundationDate,0,0)
    insert _Guild(Name, Lvl, GatheredSP, FoundationDate,Alliance,Booty) values @guildName+'_ULimit_5', 1, 0, @FoundationDate,0,0)


    insert _Guild(Name, Lvl, GatheredSP, FoundationDate,Alliance,Booty) values @guildName, 5, 0, @FoundationDate,0,0)
    set @guildID = @@identity
    
    if (@@error <> 0 or @@rowcount = 0 or @guildID = 0)
    begin
        rollback transaction
        return -5
    end


    --길드장은 퍼미션이 0xffffffff !!
    declare @rvalue int
    exec @rvalue = _Guild_FnAddMember @guildID, @CreaterID, 0, @FoundationDate,0xffffffff
    if (@@error <> 0 or @rvalue <= 0)
    begin
        rollback transaction
        return @rvalue
    end
    
    -- 길드 창고를 생성하자
    exec @rvalue = _Guild_CreateChest_NoTX @guildID
    if (@@error <> 0 or @rvalue <= 0)
    begin
        rollback transaction
        return @rvalue
    end


commit transaction
    return @guildID
    
/* Credits by Apollo : Skype apollo1337_1*/
PHP Code:
skype; apollo1337_1 
06/18/2014 03:34 PortalDark#2
#Approved