By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table TableName (id int IDENTITY(1,1) PRIMARY KEY
, FileName varchar(500))
select * from TableName
id | FileName |
---|
DECLARE @fiLePath VARCHAR(1000)
SET @fiLePath = '\\Location\DISK\YOURFOLDER\File_Name.txt'
insert into TableName
select RIGHT(@fiLePath, CHARINDEX('\', REVERSE(@fiLePath)) -1) file_name
1 rows affected
select * from TableName
id | FileName |
---|---|
1 | File_Name.txt |