• WITH Alphas AS

    (

    SELECT a

    FROM (VALUES('A'),('B'),('C'),('D')) a (a) -- use 22 letters

    ),

    Numbers AS

    (

    SELECT n

    FROM (VALUES('0'),('1'),('2')) a (n) -- use 10 digits

    )

    -- For my case 4*4*3*3*4*4*3*3 = 20,736 rows

    SELECT a.a + b.a + c.n + d.n + e.a + f.a + g.n + h.n

    FROM Alphas a

    CROSS JOIN Alphas b

    CROSS JOIN Numbers c

    CROSS JOIN Numbers d

    CROSS JOIN Alphas e

    CROSS JOIN Alphas f

    CROSS JOIN Numbers g

    CROSS JOIN Numbers h;

    I wouldn't dare run this with 22 letters and 10 digits but there you go.


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St