Follow via:
RSS
Email Alert
Question
1 Vote
+ -

sql query permutations without repetition

I need a query which can be used in (or as) a function and retrieves all permutations of n values. And I need all permutations of length k where k = 1..n.

Extended sample input and result so input has 3 values instead of 2 - however, number of input values may vary from 1 to n.

Example:

Input: table with values in one column in multiple rows

Value (nvarchar(500))
------
Ann
John
Mark

Output#1: table with values concatenated in one column

Ann
John
Mark
Ann,John
Ann,Mark
John,Mark
Ann,John,Mark
1st Dec
Answer the question
Formatting +
BB Codes - Note: HTML is not supported in forums
  • [b] Bold [/b]
  • [i] Italic [/i]
  • [u] Underline [/u]
  • [s] Strikethrough [/s]
  • [q] "Quote" [/q]
  • [ol][*] 1. Ordered List [/ol]
  • [ul][*] · Unordered List [/ul]
  • [pre] Preformat [/pre]
  • [quote] "Blockquote" [/quote]

Join the TechRepublic Community and join the conversation! Signing-up is free and quick, Do it now, we want to hear your opinion.