title: SQL Server stored procedure update else insert
body: <p>Does anyone know how I can update a row if row exists, else insert statement in a stored procedure?</p>
  
  <p>I try multiple ansvers on google, but cannot get it to work. </p>
  
  <p>My SQL Server stored procedure:</p>
  
  <pre><code>USE [mydb]
  GO
  
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  
  ALTER Procedure [dbo].[Sp_Insert_Rapport]
      (@P_STDDetails As Insert_Rapport Readonly)
  AS
  BEGIN
       INSERT INTO tblRapporter(fldCompanyID, fldMalerID, fldGodkendelsesTidspunkt, fldRapportNoegle, fldRapportVkCvrNr, fldRapportVkNr, fldRegNr, fldStatus)
           SELECT
               fldCompanyID, fldMalerID, fldGodkendelsesTidspunkt,
               fldRapportNoegle, fldRapportVkCvrNr, fldRapportVkNr,
               fldRegNr, fldStatus 
           FROM
               @P_STDDetails
  END
  </code></pre>
  
  <p>If I use</p>