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
 find character

Author  Topic 

shajimanjeri
Posting Yak Master

179 Posts

Posted - 2008-04-12 : 04:12:55
Hi all,

I have a string like '10010000001000'.
Here I need to find the 4th character of this string (in this case it should be '1') by using sql query. How to do this one?


regards
Shaji

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-12 : 04:16:18
SELECT SUBSTRING('10010000001000',4,1)
Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2008-04-12 : 05:10:44
SELECT RIGHT(LEFT('10010000001000',4),1)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-12 : 05:13:12
quote:
Originally posted by raky

SELECT LEFT('10010000001000',1)


how will this give 4th character? this will always return the first character of string from the left.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-14 : 03:11:52
quote:
Originally posted by visakh16

quote:
Originally posted by raky

SELECT LEFT('10010000001000',1)


how will this give 4th character? this will always return the first character of string from the left.


He has edited the reply

Madhivanan

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

- Advertisement -