title: Execute a stored procedure if else conditions
body: <p>I would like to know how to execute a stored procedure based on if customer id exists, create a Customer Order for the specified customer. Else, create a new customer with the specified id.</p>
  
  <p>I have some codes here however im getting an error, it says "Procedure or function 'CustOrder1' expects parameter '@custid1', which was not supplied".
   Any help would be good, thanks in advance.</p>
  
  <pre><code>declare @custid1 char (6), @CustName1 nvarchar(255)
  set @custid1 = 001
  set @custName1 = 'Pete'
  select @custid1 = 'c102', @custName1 = 'Pete'
  
  update CustomerRecord
      set CustomerID = @custid1
  where CustName = @CustName1
  
  select * from CustomerRecord where CustomerID = @custid1
  if @@ROWCOUNT = 0
      print 'The id ' + cast(@custid1 as  varchar(5)) + ' does not exists'
  else
      print 'Update successsful'
  go
  
  alter procedure CustOrder1
    @custid1 CHAR (6), @custName1 VARCHAR (40), @SalesOrderID CHAR (10)
  as
  begin
    if not exists (select * from CustomerRecord
      where CustName = @CustName1)
    begin
      insert into CustomerRecord (CustomerID)
        values (@custid1)
    end
  end
  go
  
  exec CustOrder1
  </code></pre>