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 2000 Forums
 SQL Server Development (2000)
 How to seperate a string in sqlserver

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-10-13 : 08:03:02
raja writes "HI in my backend(sqlserver2000) i have a column containing datas like asdf/asde/frfr/mmm.aspx here could any one tell me how can i fetch that mmm.aspx only by using sql queries

raja"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-13 : 08:04:00
Refer Split function here
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50648

Madhivanan

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

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-10-13 : 08:05:03
SELECT Reverse(Substring(Reverse(col1), 1, CharIndex('/', Reverse(col1))-1)) FROM myTable
Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2005-10-14 : 01:07:54
quote:
Originally posted by robvolk

SELECT Reverse(Substring(Reverse(col1), 1, CharIndex('/', Reverse(col1))-1)) FROM myTable



It's a good idea to do it like this:
SELECT Reverse(Substring(Reverse(col1), 1, CharIndex('/', Reverse('/' + col1))-1)) FROM myTable

...so you don't get errors or odd results when your original string does not contain a '/' character.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-14 : 01:17:51
blindman, Nice to see you at SQLTeam

Madhivanan

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

- Advertisement -