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)
 Substring Parse

Author  Topic 

scelamko
Constraint Violating Yak Guru

309 Posts

Posted - 2005-07-28 : 10:10:24
Hi

I have data in a column which I have to parse it into different columns according to delimiters, but I realised
substring function in SQL Server does not allow delimiters in its arguments

column Parse1 Parse2
______________________________________
AB 234/145 234 145
AB123/245 123 245

Since in the above eg I am not always sure if delimiter '/' always exists position 6 or 5, I am able to use the
substring function to parse the column and populate 243 and 145 into 2 different columns.

Any suggestions/inputs would be helpful

Thanks


madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-07-28 : 10:15:33
see if this helps you
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=51476

Madhivanan

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

scelamko
Constraint Violating Yak Guru

309 Posts

Posted - 2005-07-28 : 11:11:17
Hi,
Also is there any function to count the occurences of particular charecter like '/' in a string.

Thanks
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2005-07-28 : 11:20:00
count character

Declare @myStr varchar(100)
Set @myStr = 'sdkj/g3/28/fs8'

Select len(@myStr)-len(Replace(@myStr,'/',''))

Corey

Co-worker on The Wizard of Oz "...those three midgets that came out and danced, the freaked me out when I was little. But they are ok now."
Go to Top of Page
   

- Advertisement -