T-SQL、394バイト(ボーナスなし)
私は「なぜそうではない」と思いますか?
DECLARE @i INT, @k INT SET @i = 100 SET @k = 200 WITH g AS (SELECT @i AS n UNION ALL SELECT n+1 FROM g WHERE n+1<=@k ) SELECT LEN(n) AS c FROM (SELECT STUFF((SELECT REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(n, 1, ''), 2, ''), 3, ''), 4, ''), 5, ''), 6, ''), 7, ''), 8, ''), 9, ''), ' ', '') FROM g FOR XML PATH ('')) ,1,0,'') n ) a OPTION (maxrecursion 0)
そしてフレンドリーなもの:
-- CG!
DECLARE @i INT, @k INT
SET @i = 100
SET @k = 200
WITH g AS
(
SELECT @i AS n
UNION ALL
SELECT n+1 FROM g WHERE n+1<=@k
)
SELECT LEN(n) AS c FROM
(
SELECT
STUFF((SELECT REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(n, 1, ''), 2, ''), 3, ''), 4, ''), 5, ''), 6, ''), 7, ''), 8, ''), 9, ''), ' ', '')
FROM g FOR XML PATH ('')) ,1,0,'') n
) a
OPTION (maxrecursion 0)