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.
| Author |
Topic |
|
mawar76
Starting Member
2 Posts |
Posted - 2009-03-19 : 05:11:48
|
| Hi GuysI'm doing a grouping based on the URL domain.Can you guys help me to edit string of the URL http://www.google.com/page1.html to become www.google.comWhat functions/syntax should I be exploring here for this task?TQ |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-03-19 : 05:24:19
|
[code]DECLARE @Sample TABLE ( url VARCHAR(200) )INSERT @SampleSELECT 'http://www.google.com/page1.html' UNION ALLSELECT 'http://www.sqlteam.com' UNION ALLSELECT 'www.developerworkshop.net'SELECT url, SUBSTRING(url, case when f = 0 then 1 else f + 3 end, case when e = 0 then len(url) else e - 1 end)FROM ( SELECT url, CHARINDEX('://', url) AS f, CHARINDEX('/', SUBSTRING(url, CHARINDEX('://', url) + 3, 200)) AS e FROM @Sample ) AS d[/code] E 12°55'05.63"N 56°04'39.26" |
 |
|
|
mawar76
Starting Member
2 Posts |
Posted - 2009-03-19 : 07:22:39
|
| Thanks peso..your scripts works... |
 |
|
|
|
|
|