I need a function in sql server to build all of changed word in below example;
for input word with length n must build 2^n changed word;
For example, if the input of the function is
"I"
the output of the function should be
I
-
the input of the function is
"am"
the output of the function should be
am
-m
a-
--
the input of the function is
"sql"
the output of the function should be
sql
-ql
s-l
sq-
--l
s--
-q-
---
You can do this with a numbers table (master..spt_values) and
stuffin a loop.https://data.stackexchange.com/stackoverflow/q/122334/
Or you can use a reqursive CTE
https://data.stackexchange.com/stackoverflow/q/122337/
Update
The recursive CTE version is really slow as pointed out by OP in a comment. Using a word with 7 letters there are 960800 rows returned from the CTE.