Posted By

heathbo on 07/10/14


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Beppoi


SQL If / Else statement


 / Published in: SQL
 

Declare a newbinumber 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

  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  

You need to login to post a comment.