SQL 2000 Multiple IF Statements
Posted
by
Spidermain50
on Stack Overflow
See other posts from Stack Overflow
or by Spidermain50
Published on 2010-12-29T14:42:38Z
Indexed on
2010/12/29
14:54 UTC
Read the original article
Hit count: 138
sql
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 GOCREATE 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
© Stack Overflow or respective owner