We help IT Professionals succeed at work.

BaseURL

218 Views
Last Modified: 2010-03-19
Hi
Any one know how i can extract the baseurl from a table column and insert into another column.
i.e http://www.mysite.com/page1.aspx or http://mysite.com/page1.aspx looking to insert into a column in the same table http://www.maysite.com/ or http://mysite.com/
Thanks
George
Comment
Watch Question

AneeshDatabase Consultant
CERTIFIED EXPERT
Top Expert 2009

Commented:
SELECT LEFT(url, CHARINDEX('/',url, PATINDEX('%://%',url)+3))

Author

Commented:
Hi aneeshattingal:
I get this error when trying the following
Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.

------------------------------------

update dbo.sr_Images
set ImageBaseURL = (SELECT LEFT(imageurl, CHARINDEX('/',imageurl, PATINDEX('%://%',imageurl)+3))
from dbo.sr_Images)
Regards
George
Database Consultant
CERTIFIED EXPERT
Top Expert 2009
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Thanks aneeshattingal:
That work ok
Regards
George
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.