Thursday, March 29, 2012

Extract filename

Quick question (with hopefully a quick answer :)
Does there exist a function that turns this:
C:\projecten\33994\400134506.doc
into
400134506.doc ?
Kind regards,
Stijn Verrept.I might suggest you are better to do this splitting at the presentation
tier. Or, if only the filename is important, store only the filename.
declare @.foo varchar(64)
set @.foo = 'C:\projecten\33994\400134506.doc'
select right(@.foo, charindex('', reverse(@.foo))-1)
http://www.aspfaq.com/
(Reverse address to reply.)
"Stijn Verrept" <stijn@.no_s.p.a.n.entrysoft.com> wrote in message
news:eBK$rMqIFHA.276@.tk2msftngp13.phx.gbl...
> Quick question (with hopefully a quick answer :)
> Does there exist a function that turns this:
> C:\projecten\33994\400134506.doc
> into
> 400134506.doc ?
> --
> Kind regards,
> Stijn Verrept.|||Aaron [SQL Server MVP] wrote:

> select right(@.foo, charindex('', reverse(@.foo))-1)
Thanks, this one worked perfect :)
Kind regards,
Stijn Verrept.sql

No comments:

Post a Comment