I know I could probably just count the commas but I wanted to know if theres a built in way to count the results in a comma seperated list?
e.g
DECLARE @IDs NVARCHAR(100)
SET @IDS = '2,3,54,234,'
SELECT
COUNT(value FROM STRING_SPLIT(@IDs)) AS [Count]
FROM
Table
CodePudding user response:
Try this:
DECLARE @IDs NVARCHAR(100)
SET @IDS = '2,3,54,234,'
SELECT
COUNT(*)
FROM
STRING_SPLIT(@IDs, ',')