techmaniac15
Programmer
This SP throws a syntax error on @players declaration. That doesn't appear to be the problem though, as debugging I've determined it's somewhere else in the code... BUT WHERE!??
Code:
ALTER procedure [dbo].[Golf_ModifyPlayers]
@paramID int,
@paramPlayerNames varchar(500)
AS
declare @spot int;
declare @str varchar(500);
declare @Players TABLE
(
pid int IDENTITY(1,1) PRIMARY KEY,
Player varchar(75),
coID int
)
BEGIN
SELECT * INTO @Players FROM Golf_GetPlayers(@paramID)
END
BEGIN
DELETE FROM gtPlayers WHERE gtID = @paramID
END
SET @paramPlayerNames = LEFT(@paramPlayerNames, LEN(@paramPlayerNames) - 1)
While @paramPlayerNames <> ''
BEGIN
SET @spot = CHARINDEX(',', @paramPlayerNames)
IF @spot > 0
BEGIN
SET @str = LEFT(@paramPlayerNames, @spot - 1)
SET @paramPlayerNames = RIGHT(@paramPlayerNames, LEN(@paramPlayerNames) - @spot)
END
ELSE
BEGIN
SET @str = @paramPlayerNames
SET @paramPlayerNames = ''
END
INSERT INTO gtPlayers (PlayerName, gtID) VALUES (@str, @paramID)
END
if @@ERROR<>0 GOTO Error_Handling;
Error_Handling:
begin
RAISERROR ('Transaction rolled back.', 16, 1);
ROLLBACK TRAN;
end