title: Display a Message for Every 10000 records on console application and SQL
body: <p>I am dealing with a Console application in which it is getting 1million of records form one table which is in different server and storing in to a data table and sending the DataTable to SQL and inserting/updating in to our table using a merge statement. To get the data it is taking 25min and for inserting it takes 20min, i am using SQL-Server management studio-2012.</p>
  
  <p>I would like to give information on the front screen by displaying "10000 records are inserted/updated" for every 10000 records or by a specific time delay of 10sec.</p>
  
  <p>Is there a way to achieve this using the SQL(for every 10000 records updated, need to send a message to App) or by Console Application. Below is my Stored procedure using for it.</p>
  
  <pre><code>ALTER PROCEDURE [dbo].[sp_Data_Inserting_In_To_QueueTable]
  
      -- Add the parameters for the stored procedure here
      @Values AS [dbo].[Type_Table] READONLY  
  
  AS
  
  BEGIN
  
      SET NOCOUNT ON;
  
      ;WITH CTE_data_codes AS(
          select [NO], [ID], [Name], [Code]  from @SearchValues where [No] != '0'
          )
  
      MERGE tbl__QueueTable_Codes AS t
          -- Values is the temp table in which data is coming from the console application
          USING CTE_data_codes  AS s
          ON (s.Code = t.Code and s.NO = t.NO and s.ID = t.ID)
  
  
          WHEN NOT MATCHED by target
              --Newly added values in Values has been updated in tbl__QueueTable_Codes
              THEN INSERT(NO, Name, ID, Code, Deleted)
              VALUES(s.[NO], s.[Name], s.[ID], s.[Code], 0)
  
           WHEN NOT MATCHED by source
              --It means the value has been deleted in Value, hence we put a flag for deleted ones as '1'.
              THEN  UPDATE            
              SET t.Deleted = 1;
  
  END
  </code></pre>