IF Clause in SQL Stored Procedure - TechRepublic
General discussion
December 18, 2000 at 02:30 AM
frankus

IF Clause in SQL Stored Procedure

by frankus . Updated 25 years, 6 months ago

I am converting an Access97 SQL statement with several nested IIF clauses to MS SQL-7.0
I tried to do it with IF/ELSE as follows:

IF (TableA.Field1 = 21 or TableA.Field1 = 22)
SET @Amount = @Amount + TableA.Field2
ELSE
IF (TableA.Field1 = 24)
SET @Reserve = @Reserve + TableA.Field2
——
Eventually I want to UPDATE the table with the two declared @ Variables.
The Syntax checks OK in Query Analyzer, but tells me there is no TableA when I run it.
What am I doing wrong? An INSERT part into TableA in the same procedure, located before this, works OK.

This discussion is locked

All Comments