Cross Join 'n' times a table

Posted by SDReyes on Stack Overflow See other posts from Stack Overflow or by SDReyes
Published on 2010-05-11T21:40:48Z Indexed on 2010/05/11 21:44 UTC
Read the original article Hit count: 336

It is possible to write a generic function/procedure/select/somethingElse to cross-join a table against himself 'n' times? (yes, 'n' is a given parameter : )

How would you do it?


Example

Having this table:

 Value
-------
   1
   2
   3 

cross join it 2 times, would return:

 Value  | Value
------------------
    1       1
    1       2
    1       3
    2       1
    2       2
    2       3
    3       1
    3       2
    3       3

© Stack Overflow or respective owner

Related posts about sql-server-2008

Related posts about sql