我似乎无法找到有关如何执行此操作的任何信息。关于如何从基数36转换而不是如何进行计数的大量文章。我需要从0000到zzzz。有没有人这样做过?
答案 0 :(得分:2)
WITH
num AS (SELECT TOP 36 ROW_NUMBER() OVER(ORDER BY (SELECT 1)) i FROM master.dbo.spt_values),
chr AS (SELECT i,CASE WHEN i <= 10 THEN CHAR(i+47) ELSE CHAR (i+54) END c FROM num)
SELECT t3.c + t2.c + t1.c + t0.c
FROM chr t3, chr t2, chr t1, chr t0
ORDER BY t3.i, t2.i, t1.i, t0.i