title: Insert and update stored procedure with parameters and default of zero doesn't work
body: <p>I need help to create an insert stored procedure with parameters, if pass the value for that parameter, then it has to insert or update in database, else it should use a default of zero.</p>
  
  <p>My problem is that when I execute the code below using a <code>SampleID = 0</code>, it works... any other <code>SampleID</code> does nothing.</p>
  
  <p>Thanks in advance</p>
  
  <p>Execution of the stored procedure:</p>
  
  <pre><code>SET NOCOUNT OFF
  EXEC SP_Samples '0',  '3'  ,'Pink'
  GO
  </code></pre>
  
  <p>Stored procedure code:</p>
  
  <pre><code>SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO              
  
  ALTER PROCEDURE [dbo].[SP_Samples]
      (@SamplesID int, 
       @SamplesCategoriesID int,
       @SamplesName nvarchar(50)
      )
  AS
  BEGIN
      SET NOCOUNT ON;
  
      IF (@SamplesID = 0)
      BEGIN
          INSERT INTO tblSamples ([SamplesName], [SamplesCategoriesID])
          VALUES (@SamplesName, @SamplesCategoriesID)
      END
      ELSE
      BEGIN
          UPDATE [tblSamples]
          SET SamplesCategoriesID = @SamplesCategoriesID,
              SamplesName = @SamplesName 
          WHERE SamplesID = @SamplesID
      END      
  END
  </code></pre>