Matt writes "Can you use an IF ELSE IF in a cursor. I need to assign variables in to be evaluated, then based on the evaluation apply a formula on the other variables. Something like this:
declare @selLineItemId float
declare @Lengthunits varchar(50)
declare @Widthunits varchar(50)
declare @Length varchar(25)
declare @Width varchar(25)
declare @Area varchar(25)
DECLARE c1 CURSOR FOR
Select a.idx, a.configuredLengthX, a.configuredLengthUnitsOfMeasurX, a.configuredWidthX, a.configuredWidthUnitsOfMeasureX
from selLineItemT a, poHub b
where a.idx = b.SelLineItemID
OPEN C1
FETCH NEXT FROM c1
into @selLineItemId, @Length, @Lengthunits, @Width, @Widthunits
WHILE @@FETCH_STATUS = 0
BEGIN
IF (@Lengthunits = 'yards')
@Length * 36
@Length = @Area
@Area = 0
(@Lengthunits) = 'feet'
Else IF (@Lengthunits = 'feet')
BEGIN
@Area = @Length * 12
@Length = @Area
@Area = 0
END
@Area = (@Length*@Width)/1000
print @Area
FETCH NEXT FROM c1
into @selLineItemId, @Length, @Lengthunits, @Width, @Widthunits
END
CLOSE c1
DEALLOCATE c1"