Author |
Topic |
gagani
Posting Yak Master
112 Posts |
Posted - 2015-07-21 : 11:29:41
|
I want to extract a number within a column results, that is the number between the first two commasExample:select path from tablea results:1158285,1158286,1158287,1158288,11582891158288,1158289,1158290,1158291,1158292....How to extract the second number(between the first two commas) from the above results?the output should be11582861158289 |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2015-08-04 : 08:42:08
|
[CODE]declare @tablea table(Data varchar(1000))insert @tableaSELECT '1158285,1158286,1158287,1158288,1158289' union allSELECT '1158288,1158289,1158290,1158291,1158292'SELECT SUBSTRING(RIGHT(data, LEN(Data)-CHARINDEX(',', Data)), 1, CHARINDEX(',',RIGHT(data, LEN(Data)-CHARINDEX(',', Data)))-1), Data FROM @tablea[/CODE]--Chandu |
|
|
Paramasivan B
Starting Member
5 Posts |
Posted - 2015-09-30 : 04:35:23
|
declare @a varchar(100)='1158285,1158286,1158287,1158288,1158289'select substring(@a,charindex(',',@a)+1,charindex(',',@a,charindex(',',@a)+1)-charindex(',',@a)-1)Paramasivan B |
|
|
|
|
|