Technical Article

Script to count the number of Yes/No in the string

,

    Script showing how to count the number of Yes /No answers in the string
    Inspired by tip that didn't work on Microsoft website



/* 
*Script showing how to count the number of Yes /No answers in the string 
*/
declare @yesno varchar(10)
set @yesno ='YNNYNNYNNY'

SELECT len( REPLACE(@yesno,'N',isnull(space(0),''))) 'Yes',len(REPLACE(@yesno,'Y',isnull(space(0),''))) 'No'

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating