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 2005 Forums
 Transact-SQL (2005)
 String manipulation

Author  Topic 

shpinoza1980
Starting Member

17 Posts

Posted - 2011-02-13 : 07:39:27
Hello,

I have a nvarchar column called [url] with data like:

http://google.news.........http://www.mysite.com

For every row I need to SPLIT the data on the second 'http://'
so the update results for this column will be (for the row above)
(get rid of the first http:// in the string)
http://www.mysite.com





thanks a lot

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-02-13 : 09:06:58
[code]select substring(url, charindex('http://', url, charindex('http://', url) + 1), len(url))[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-02-13 : 09:09:11
replace @a with the column name and check if works for your case!

reverse(substring(reverse(@a),0,patindex('%//:ptth%',reverse(@a))+7))
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-02-14 : 05:42:30
or

declare @s varchar(1000)
set @s='http://google.news.........http://www.mysite.com'
select right(@s,CHARINDEX('//:ptth',reverse(@s))+6)

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

shpinoza1980
Starting Member

17 Posts

Posted - 2011-02-14 : 08:09:25
thanks all,

I've used madhivanan solution, works great

thanks a lot
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-02-14 : 09:18:52
quote:
Originally posted by shpinoza1980

thanks all,

I've used madhivanan solution, works great

thanks a lot


You are welcome

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -