Q&A about the site for administrators, end users, developers and designers for Craft CMS
declare @S varchar(20) set @S = '123456' while len(@S) > 0 begin print left(@S, charindex(',', @S+',')-1) set @S = stuff(@S, 1, charindex(',', @S+','), '') end DECLARE @OldUseIds VARCHAR(3000); DECLARE @NewUseIds VARCHAR(3000); DECLARE @OldCount INT; DECLARE @NewCount INT; SET @OldUseIds = '082,086,179,309,433,635,694,726,982'; SET @NewUseIds = '001,002,003,004,005,006,007,008,009'; SET @OldCount = LEN(@OldUseIds) - LEN(REPLACE(@OldUseIds, ',', '')) +1; SET @NewCount = LEN(@NewUseIds) - LEN(REPLACE(@NewUseIds, ',', '')) +1; PRINT @OldCount PRINT @NewCount