SQL Select question: Find character in a string

given a cell in column TOPIC, how do I write a select where the X position of a character in a cell results in a 1?  The cell is in nvarchar and always contains a string of 1's and zeroes

For example, consider a row of data:
TOPIC:  10110000110011101
TITLE:   MyTitle
NAME:  MyName

Select NAME from DBO.Workshops where Title = 'MyTitle' AND <the 4th character of TOPIC = '1'>

How do I write the part
'the 4th character of TOPIC = '1'
Who is Participating?
BrandonGalderisiConnect With a Mentor Commented:
Here you go
Select NAME from DBO.Workshops where Title = 'MyTitle' 
and substring(topic,4,1)='1'

Open in new window

try this
append this with the where condition

and substring(Topic, 4, 1) = '1'

for a generalized way of writitng it, pass teh position as parameter to teh query
substring(Topic, n, 1)
where 'n' is the postion you wnat to know the value of ?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.