title: Insert statement with CASE to avoid duplicate row insertion
body: <p>I have written the below stored procedure for checking for duplicates before inserting the row into the table.</p>
  
  <p>But I cannot write my <code>INSERT</code> statement inside the <code>CASE</code>.</p>
  
  <p>How can I write stored procedure for checking the value of <code>@Ordername</code> and after that if it is not present then it should be inserted into database .</p>
  
  <pre><code>       CREATE PROCEDURE [Test Procedure ]
            (
            @section varchar(70), 
            @mark varchar(70),
            @qty decimal(18,2),
            @Weight decimal(18,2),
            @dateupdateremark int,
            @OrderName varchar(70)
             )
            AS
         BEGIN
     SET NOCOUNT ON;
  
         select case(@OrderName)
         when (select OrderName from dbo.tbl_insertxmldetails 
         where(@OrderName) not in (select OrderName from tbl_insertxmldetails))
  
         then 
         insert into dbo.tbl_insertxmldetails 
         (Section, Mark, QTY,Weight,Dateupdateremark ,OrderName,SystemDate)
         values
         (@Section, @Mark, @QTY,@Weight, @Dateupdateremark,@OrderName,GETDATE())
         else 'File already Exists'
   end
  </code></pre>