• + 0 comments

    use cursor

    declare contro cursor scroll for select A,B,C from TRIANGLES 
    open contro;
    declare @canh1 int, @canh2 int, @canh3 int;
    fetch next from contro into @canh1,@canh2,@canh3
    while @@fetch_status = 0
    begin 
    if (@canh1 + @canh2 > @canh3) and(@canh1 + @canh3 > @canh2) and(@canh3 + @canh2 > @canh1) begin
        if @canh1 = @canh2 and @canh2 = @canh3 and @canh1 = @canh3
            print 'Equilateral'; 
        else if (@canh1 = @canh2 and @canh1 != @canh3) or (@canh2 = @canh3 and @canh2 != @canh1) or (@canh1 = @canh3 and @canh1 != @canh2)
            print 'Isosceles';
        else
            print 'Scalene';
        end
    else
        print 'Not A Triangle';
        fetch next from contro into @canh1,@canh2,@canh3
    end