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

Share

Share

Rate