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
 General SQL Server Forums
 New to SQL Server Programming
 How do I read number after the "/" in the above ?

Author  Topic 

Vaishu
Posting Yak Master

178 Posts

Posted - 2008-07-29 : 08:02:39
Hi

I have coloum in table containing string like below

ex:
SDFRT56789-1/9
GHJKYUURE/2
12SDF-PR-1/1
QWER45TY/3
.....
.....

How do I read number after the "/" in the above string

Advance thanks

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2008-07-29 : 08:07:33
SELECT RIGHT(yourString,1), if it's always last in the string

Jim
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-07-29 : 08:37:04
or use charindex() to find the position of '/' and use substring() to extract it.


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

VGuyz
Posting Yak Master

121 Posts

Posted - 2008-07-29 : 09:39:55
This would help you,

SELECT substring('QWER45TY/3',charindex('/','QWER45TY/3')+1,len('QWER45TY/3'))

or

select right('QWER45TY/3',(len('QWER45TY/3')-charindex('/','QWER45TY/3')))



If there any issues,let me know
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2008-07-29 : 09:46:40
select substring(@string,charindex('/',@string)+1,1)

jim
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-07-29 : 09:46:55
or If your data dont have '.',


declare @t varchar(100)
set @t ='SDFRT56789-1/9'
select parsename(replace(@t,'/','.'),1)

Madhivanan

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

- Advertisement -