Because of an old application with a lot of errors I'm often forced to update multiple (100-1000) rows in our database manually. Usually I receive the values I have to change in a Excel sheet.
I currently update them by doing something like this. Imagine that there are hundreds of rows instead of two. I usually edit them in VSCODE with regex and paste them in. But this feels clunky and prone to errors. Doing this to hundreds of rows its easy to accidentally delete one number or add another.
Is there a better way? I fully understand that the real answer is to fix all the bad code, and we are working on that. But in the mean time this is my reality.
BEGIN TRANSACTION
CREATE TABLE #TMP_PEOPLE
(
TMPEmployeeID INT,
TMPAddress NVARCHAR(60)
)
INSERT INTO #TMP_PEOPLE
VALUES (1, '123 Fo-bar way'),
(2, '321 Bar-fo Street')
UPDATE Northwind.dbo.Employees
SET Northwind.dbo.Employees.Address = TMPAddress
FROM #TMP_PEOPLE
INNER JOIN Northwind.dbo.Employees ON EmployeeID = #TMP_PEOPLE.TMPEmployeeID
COMMIT TRANSACTION