title: How to keep a variable in sql stored procedure constant and unchanged in every call to the stored procedure
body: <p>I have a stored procedure <code>up_InsertEmployees</code>. I have a functionality where I am uploading a batch of employee details into the web application. This functionality inserts the employees details into the DB using the above mentioned stored procedure. </p>
  
  <p>The stored procedure goes something like this</p>
  
  <pre><code>create procedure 'sp_InsertEmployees'
      (@EmployeeUN,
       @FirstName,
       @LastName,
       @City, @Ref)
  BEGIN
      declare @BatchRef varchar(20) 
  
      set @BatchRef = @Ref+GetUTCDate()
  
      Insert into Employee(EmployeeUN, FirstName, LastName, City, BatchRef) 
      Values(@EmployeeUN, @FirstName, @LastName, @City, @BatchRef)
  END
  </code></pre>
  
  <p>Here the column <code>Ref</code> holds the reference of the batch upload that I have performed. The value <code>BatchRef</code> has to be the same for all the employees of that particular batch. Since I am using <code>GetUTCDate()</code> the value of <code>BatchRef</code> might change with every employee that is being inserted. Can somebody please let me know how I can calculate the value of <code>BatchRef</code> when the first employee is being inserted and then keep it constant there on? I want this to be done in SQL only and not in the code. And also I want the <code>datetime</code> value to be in <code>BatchRef</code> so that each batch values are unique.</p>