SQL 2000 Multiple IF Statements
- by Spidermain50
I get a error when I try to use multiple IF statements. This is the error...
"Msg 156, Level 15, State 1, Procedure fnTNAccidentIndicator, Line 81
Incorrect syntax near the keyword 'END'."
This is the structure of my code...
USE SS_TNRecords_Accident
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION dbo.fnTNAccidentIndicator
(
@inAccidentNumber nvarchar,
@inIndicatorMode int
)
RETURNS nvarchar
AS
BEGIN
DECLARE @AlcoholInd nvarchar
DECLARE @DrugInd nvarchar
DECLARE @SpeedInd nvarchar
DECLARE @ReturnValue nvarchar
SET @AlcoholInd = '1'
SET @DrugInd = '2'
SET @SpeedInd = '3'
SET @ReturnValue = 'N'
IF (@inIndicatorMode = @AlcoholInd)
BEGIN
--select statment
IF (@@ROWCOUNT > 0)
BEGIN
@ReturnValue = 'Y'
END
END
IF (@inIndicatorMode = @DrugInd)
BEGIN
--select statment
IF (@@ROWCOUNT > 0)
BEGIN
@ReturnValue = 'Y'
END
END
IF (@inIndicatorMode = @SpeedInd)
BEGIN
--select statment
IF (@@ROWCOUNT > 0)
BEGIN
@ReturnValue = 'Y'
END
END
Return @ReturnValue
END
GO