padtes 30 Junior Poster in Training

I have a T-SQL function (transact SQL is SQL server 2005 programming language, with many limitations compared to say C# or Java). It currently works but has severe limitations.

Its input is string (formula) that has ternary operators used in it. The function converts it into CASE statement and returns it.
For ex. input: a>0?111:222 will be output as case when a>0 then 111 else 222 end The function works as long as there is no brackets nesting in various levels alongwith use of use of math binary operators. For ex. (a>0?(b>0?2:3):(c=1?(d=1?4:5)+(e=1?6:7):8)) and output expected is (with or withour brackets is Ok. Formatting /indetations optional)

case 
 when a>0 then 
  case when b>0 then 2 else 3 end
 else
  case when c=1 then
    case when d=1 then 4 else 5 end 
 + case when e=1 then 6 else 7 end 
  else
    8 end

This can get as complex as allowed.

If there are any points that will help are greatly appreciated. If there are code samples of similar problems (or URL to) is equally appreciated.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.