-2

Below is the variable in Oracle I need to convert in SQL Server please suggest.

V_BAD_EMAIL_CNT NUMBER :=  REGEXP_COUNT(pv_bad_emails,',') + 1;
Dale K
  • 25,246
  • 15
  • 42
  • 71
Sag
  • 9
  • 2

1 Answers1

1

This will return the number of comma's in the string + 1 in SQL

 declare @pv_bad_emails varchar(1000);
 set @pv_bad_emails = 'a,b,c,d';
 select len(@pv_bad_emails) - len(replace(@pv_bad_emails, ',', '')) + 1

For more reference

How do you count the number of occurrences of a certain substring in a SQL varchar?

Dale K
  • 25,246
  • 15
  • 42
  • 71
SV_
  • 34
  • 4