Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
A column named as filepath in which stored files' path.For example, d:\temp\myorder\aaa.pdfd:\temp\myorder\bbb.pdf...How to code to read from filepath and then insert into another column filename? That isaaabbb...
Start with thisdeclare @s varchar(100)set @s='d:\temp\myorder\aaa.pdf'select right(@s,charindex('\',reverse(@s))-1) as [file_name]MadhivananFailing to plan is Planning to fail
Sun Foster
Aged Yak Warrior
515 Posts
Posted - 2010-05-12 : 08:53:35
Thank you.Based on Madhivanan's code, I modified it as below and got file name:select left((right(@s,charindex('\',reverse(@s))-1)), LEN(right(@s,charindex('\',reverse(@s))-1))-4)
ms65g
Constraint Violating Yak Guru
497 Posts
Posted - 2010-05-12 : 22:00:55
If the name has not any dot character in it (else the extension) you can use this alternate also: