IF Clause

  • Quick one

    Does an IF clause always have to be followed by an ELSE clause.

    If (select count(*) from table) > x

    Then fire code.

    Otherwise do nothing.

  • No you dont have to specify an else to do nothing

    declare @i int = 1

    if @i = 0

    begin

    select 0

    end

    Will just result in a "Command(s) completed successfully" message as it has nothing to do.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply