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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 How to replace file extension?

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2007-01-18 : 08:48:46
Adam writes "I have a column containing filenames & path. E.g. \\ServerName\FolderName\User\xxxxx.1 . The extension can be .1 or .2 or .999999. I need to rename them to .DOC. Any suggestion?

Thanks."

nr
SQLTeam MVY

12543 Posts

Posted - 2007-01-18 : 09:05:08
left(path, len(path) - charindex('.',reverse(path))) + '.doc'

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-01-18 : 09:16:42
or

Stuff(path, charindex('.', path) + 1, len(path) - charindex('.', path), 'Doc')


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-18 : 09:26:12
Let's hope there is only one ".".


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -