views:

48

answers:

1

Recently a friend of mine has shown me a question as under

declare @t table(data varchar(50))
insert into @t 
 select '    
        _   
       |_  |_   '

God knows from where he got this idea ! How can I find that it is CL

How to do that in a set-based manner? Thanks a lot

A: 

It is possible to do it. You have to do string manipulation and the map each string to the character it represents. Check the site that posted that challenge here. You have to use CTE to do it in a set based statement. You can have a table like:

select ' _ | ||_|', 0 union all
select '     |  |', 1 ...

This will allow you to map the character to the numbers with a simple join.

I am sorry I do not post my full solution to this challenge here, but this question is still going on and they will be posting the best solution in about a month. The whole idea of these challenges is to try to find how to do it and learn in the process.

Jose Chama