command to find specific value in select
-
Help!!! How can I find specific value from a field in a select list where the specific value varies in position. ex; Record1 A-'Telec:144' Record1 B-'Telecom:145' How to find the ":" using the SQL so I can get the 2 value in one field.. pls.. Dabuskol
Dabsukol
-
Help!!! How can I find specific value from a field in a select list where the specific value varies in position. ex; Record1 A-'Telec:144' Record1 B-'Telecom:145' How to find the ":" using the SQL so I can get the 2 value in one field.. pls.. Dabuskol
Dabsukol
Use substring to get the characters, and charindex to find the :
declare @a varchar(20)
set @a = 'Telec:144'
select substring(@a,1,charindex(':',@a)-1),substring(@a,charindex(':',@a)+1,len(@a))will return Telec for the first 1 and 144 for the 2nd
Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP
-
Use substring to get the characters, and charindex to find the :
declare @a varchar(20)
set @a = 'Telec:144'
select substring(@a,1,charindex(':',@a)-1),substring(@a,charindex(':',@a)+1,len(@a))will return Telec for the first 1 and 144 for the 2nd
Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP
-
You are correct... Thanks for the immediate reply you save me on my last minute. Thanks...
Dabsukol