Change drive path

I am moving video from an old array to a new one. The sql table (dbo.videofiles) for the video has a column simply called filename. It shows the file path to each file which is currently Z:\video\filename. I want to point the file path to X:\video\filename but, sql doesn't like the Z: or X:. without manually going through hundreds of thousands of rows, how do I tell sql to change Z: to X:? Thank you in advance

If you need to update file paths in a table, you can safely use REPLACE() to transform the old drive prefix into the new one. Be cautious when running UPDATE statements in a production environment—always validate the result first and ensure proper backups.

DECLARE @Filepath VARCHAR(256);
SET @Filepath = 'Z:\video\filename.mp4';

SELECT
@Filepath AS Filepath_old,
REPLACE(@Filepath, 'Z:', 'X:') AS Filepath_new;

Updating the entire table:

UPDATE dbo.videofiles
SET [Filename] = REPLACE([Filename], 'Z:', 'X:')
WHERE [Filename] LIKE 'Z:%';

This answer was refined with the assistance of AI‑generated text to improve clarity and professionalism.

If the filename column stores the full path as text, you can update the drive letter with REPLACE() instead of changing each row manually. For example: UPDATE dbo.videofiles SET filename = REPLACE(filename, 'Z:\video\', 'X:\video\') WHERE filename LIKE 'Z:\video\%'; I would run a SELECT with the same REPLACE() first to preview the affected rows, and make a backup before running the update on hundreds of thousands of records.