I've create a series of short commands that make some modifications to some tables. I figured since they must happen sequentially that I would create a stored procedure that runs all of them. It works fine, but I worry that as the database grows and each command takes more time, that the commands will overlap each other and fail. Here is the code - (please forgive the different styles, I fully admit to blatant plagiarisms when coding).
Can I improve this so my commands won't overlap? Any other comments are also welcome.
Code:
CREATE PROCEDURE Deactivate_Accounts
@PathFileName varchar(100)
AS
--Clear old values from table
TRUNCATE TABLE Inactive_Employees
--Populate Table
DECLARE @SQL varchar(2000)
-- Valid format: Jsmith,John,Smith,Franklin
SET @SQL = "BULK INSERT Inactive_Employees FROM '"+@PathFileName+"' WITH (FIELDTERMINATOR = ',') "
EXEC (@SQL)
--Add GUID to Inactive_Employees table
UPDATE Inactive_Employees
SET tpGUID = tps_guid
FROM Inactive_Employees
Inner Join tps_user
ON Inactive_Employees.stUserID = tps_user.tps_title
--Delete inactive employees from user_group table
DELETE tps_user_group
FROM tps_user_group
INNER JOIN Inactive_Employees ON Inactive_Employees.tpGUID = tps_user_group.tps_user_id
--Mark inactive employees as deleted
UPDATE tps_user
SET tps_deleted = '1'
WHERE
tps_title IN (SELECT stUserID FROM Inactive_Employees)
AND
tps_deleted <> '1'
Can I improve this so my commands won't overlap? Any other comments are also welcome.