BaseURL

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
ImInNeedOfHelpAsked:
Who is Participating?
 
Aneesh RetnakaranDatabase AdministratorCommented:
first do a select statement

SELECT imageurl, LEFT(imageurl, CHARINDEX('/',imageurl, PATINDEX('%://%',imageurl)+3))
from dbo.sr_Images

then update the table in case u dont get any error


update dbo.sr_Images
set ImageBaseURL =LEFT(imageurl, CHARINDEX('/',imageurl, PATINDEX('%://%',imageurl)+3))
from dbo.sr_Images

0
 
Aneesh RetnakaranDatabase AdministratorCommented:
SELECT LEFT(url, CHARINDEX('/',url, PATINDEX('%://%',url)+3))
0
 
ImInNeedOfHelpAuthor 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
0
 
ImInNeedOfHelpAuthor Commented:
Thanks aneeshattingal:
That work ok
Regards
George
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.