?
Solved

BaseURL

Posted on 2007-10-01
4
Medium Priority
?
191 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
0
Comment
Question by:ImInNeedOfHelp
  • 2
  • 2
4 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 19989486
SELECT LEFT(url, CHARINDEX('/',url, PATINDEX('%://%',url)+3))
0
 

Author Comment

by:ImInNeedOfHelp
ID: 19989505
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
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 2000 total points
ID: 19989519
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
 

Author Comment

by:ImInNeedOfHelp
ID: 19989568
Thanks aneeshattingal:
That work ok
Regards
George
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question