日期:2014-05-17 浏览次数:20519 次
WITH Digits AS (
SELECT 0 as Number
UNION SELECT 1
UNION SELECT 2
UNION SELECT 3
UNION SELECT 4
UNION SELECT 5
UNION SELECT 6
UNION SELECT 7
UNION SELECT 8
UNION SELECT 9
)
SELECT
(d5.Number * 100000)
+ (d4.Number * 10000)
+ (d3.Number * 1000)
+ (d2.Number * 100)
+ (d1.Number * 10)
+ d0.Number as Number INTO #t
FROM
Digits AS d0
, Digits AS d1
, Digits AS d2
, Digits AS d3
, Digits AS d4
, Digits AS d5
ORDER BY Number
SELECT RIGHT('000000'+CONVERT(VARCHAR(7),number),7) FROM #t