USE [Server01]
GO
/****** Object: StoredProcedure [dbo].[cabal_tool_giveitemtoall] Script Date: 08/25/2013 15:39:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- Author: mrmagoo (Chumpy)
-- Purpose: Give an item to all accounts, or all online accounts only
ALTER PROCEDURE [dbo].[cabal_tool_giveitemtoall]
(
@itemidx int,
@itemopt int,
@durationidx int,
@onlineonly int = 1 -- 0 = all accounts, 1 = online only
)
AS
begin
DECLARE @UserNum int, @IsOnline int, @ServerIdx int
SET @serveridx=server01.dbo.GetServerIdx()
DECLARE CURSOR_ACCOUNTS CURSOR FOR
SELECT UserNum,[Login]
FROM account.dbo.cabal_auth_table
OPEN CURSOR_ACCOUNTS
FETCH NEXT FROM CURSOR_ACCOUNTS
INTO @UserNum,@IsOnline
WHILE @@FETCH_STATUS = 0
BEGIN
IF (@onlineonly = 1)
BEGIN
IF (@IsOnline = 1)
INSERT INTO cabalcash.dbo.MyCashItem( UserNum, TranNo, ServerIdx, ItemKindIdx, ItemOpt, DurationIdx )
VALUES (@UserNum, '1', @serveridx,@itemidx,@itemopt,@durationidx )
END
ELSE
INSERT INTO cabalcash.dbo.MyCashItem( UserNum, TranNo, ServerIdx, ItemKindIdx, ItemOpt, DurationIdx )
VALUES (@UserNum, '1', @serveridx,@itemidx,@itemopt,@durationidx )
FETCH NEXT FROM CURSOR_ACCOUNTS
INTO @UserNum,@IsOnline
END
CLOSE CURSOR_ACCOUNTS
DEALLOCATE CURSOR_ACCOUNTS
END