I have a stored procedure up_InsertEmployees
. 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.
The stored procedure goes something like this
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
Here the column Ref
holds the reference of the batch upload that I have performed. The value BatchRef
has to be the same for all the employees of that particular batch. Since I am using GetUTCDate()
the value of BatchRef
might change with every employee that is being inserted. Can somebody please let me know how I can calculate the value of BatchRef
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 datetime
value to be in BatchRef
so that each batch values are unique.