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.
| Author |
Topic |
|
slimt_slimt
Aged Yak Warrior
746 Posts |
Posted - 2008-11-13 : 12:08:43
|
hideclare @string varchar(100)set @string = '(12345) text'--set @string = '(2323234) texttext'select @string,substring(@string, 2,5) i want to get information in parathesis (without paranthesis) out of this string and also text, both separately. Just that lenght of substring in paranthesis is not always the same, same goes for text.thank you for the hint. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-13 : 12:25:45
|
| [code]SELECT REPLACE(LEFT(@string,CHARINDEX(')',@string)-1),'(','') as numbervalue,SUBSTRING(@string,CHARINDEX(')',@string)+2,LEN(@string)) as textvalue[/code] |
 |
|
|
slimt_slimt
Aged Yak Warrior
746 Posts |
Posted - 2008-11-13 : 12:29:57
|
thank you visakh16.and my solution:select @string,substring(@string, charindex(')',@string)+1 ,len(@string)) as text_part,replace(reverse(right(reverse(@string), len(@string)-charindex(')', reverse(@string)))), '(','') as int_part |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-11-14 : 01:31:58
|
orselect parsename(string,2),parsename(ltrim(String),1) from( select replace(replace(@string,')','.'),'(','.') as string) as tMadhivananFailing to plan is Planning to fail |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2008-11-17 : 05:53:56
|
| declare @string varchar(100)set @string = '(12345) text'select substring(@string,Charindex('(',@string)+1,charindex(')',@String)-2) as numericvalue,SUBSTRING(@string,CHARINDEX(')',@string)+2,LEN(@string)) as textvalueI Struggle For Excellence |
 |
|
|
|
|
|
|
|