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 2008 Forums
 Transact-SQL (2008)
 Simple update with string

Author  Topic 

mike13
Posting Yak Master

219 Posts

Posted - 2011-10-24 : 16:34:21
Hi all,

i need to update a ton of records.
Records look like ex:

Hoodies/tribal2/hoodie_0135.jpg
Hoodies/tribal2/big/hoodie_135.jpg

i just want to keep the last part of the record
ex:
hoodie_0135.jpg
hoodie_135.jpg

How can i do this?
thanks a lot

vijays3
Constraint Violating Yak Guru

354 Posts

Posted - 2011-10-24 : 17:11:02
can you provide more sample data?
Go to Top of Page

mike13
Posting Yak Master

219 Posts

Posted - 2011-10-24 : 17:13:07
Hoodies/tribal2/hoodie_0135.jpg
Hoodies/tribal2/big/hoodie_135.jpg

i just want to keep the last part of the record
ex:
hoodie_0135.jpg
hoodie_135.jpg

it is just cutting the string on the last /
in vb i would left("Hoodies/tribal2/big/hoodie_135.jpg",instrrev("/"))
Go to Top of Page

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2011-10-24 : 17:17:49
declare @fpath varchar(300)
set @fpath = 'Hoodies/tribal2/hoodie_0135.jpg'

SELECT REVERSE(SUBSTRING(REVERSE(@fpath), 0, CHARINDEX('/', REVERSE(@fpath), 1)))


Success is 10% Intelligence, 70% Determination, and 22% Stupidity.
\_/ _/ _/\_/ _/\_/ _/ _/- 881
Go to Top of Page

mike13
Posting Yak Master

219 Posts

Posted - 2011-10-25 : 02:06:12
Thank a lot Vinnie that did the trick
Go to Top of Page
   

- Advertisement -