I'm running into an ELSE syntax error and would really appreciate a 2nd set of eyes to show me what is wrong! I'm using SSMS v17.3. The message I am receiving is:
Msg 156, Level 15, State 1, Line 98
Incorrect syntax near the keyword 'ELSE'.
Line 98 is the last ELSE before the go. About 6 lines above the end of the entire statement. Thank you in advanced!
DECLARE @GroupID uniqueidentifier
DECLARE @fCompID int
DECLARE @fPropID int
DECLARE @fCompGUID uniqueidentifier
Set @GroupID = 'E63DC5E7-C8C8-4EA3-B1BF-75712DD83EF4'
SET @fCompID = '0'
SET @fPropID = '0'
WHILE @fCompID <= '999'
BEGIN
IF @fCompID = (SELECT fID FROM tSCCompany WHERE fID = @fCompID)
SET @fCompGUID = (SELECT fCompanyID FROM tSCCompany WHERE fID = @fCompID)
WHILE @fPropID <='999'
BEGIN
IF @fPropID = (SELECT fID FROM tSCProperty WHERE fID = @fPropID AND fCompanyID = @fCompGUID)
BEGIN
INSERT INTO zPropTest(fGroupID, fPropertyID)
Select @GroupID, (select fPropertyID from tSCProperty where fID = @fPropID AND fCompanyID = @fCompGUID)
SET @fPropID = @fPropID + 1
END
ELSE
BEGIN
SET @fPropID = @fPropID + 1
END
END
ELSE
BEGIN
SET @fCompID = @fCompID + 1
SET @fPropID = '0'
END
END
GO
Aucun commentaire:
Enregistrer un commentaire