SQL: If / Else statement


/ Published in: SQL
Save to your folder(s)

Declare a new_bi_number variable
Set the new variable
If the new variable is null, set it to 1000
Select it to show it
If the new variable is not null, Select it to show it


Copy this code and paste it in your HTML
  1. DECLARE @new_bi_number VARCHAR(10)
  2.  
  3. SELECT @new_bi_number = invoice_next_avail_number FROM bi_broker_invoice_number WHERE mx_company_id = 1 AND broker_invoice_type_id = 1
  4.  
  5. IF @new_bi_number IS NULL
  6. BEGIN
  7. SET @new_bi_number = 1000
  8. SELECT @new_bi_number
  9. END
  10. ELSE
  11. SELECT @new_bi_number

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.