Wednesday, March 28, 2012

Normalized Data, Not

My boss whats me to collect data in a way that will allow him to view it in a non-normalized view...

name phone_type_1, sn_phone_type_1, phone_type_2, sn_phone_type_2, phone_type_3, sn_phone_type_3...

He does NOT want...

name, phone_type, sn_phone_type
Bill ATT XX44YY
Bill ATT QQ66TT
Bill DELL 77JJ88

So how can I collect the data in a normalized fashion, then display it in the format he desires? If possible I really didn't want to write code to step through the records splitting them up, Id like to use SQL.

Thanks in advance for your suggestions.Collect it normalized like you want to. Then go like this:

declare @.foo varchar(8000)

select @.foo = coalesce (@.foo + ',', '')
+ phone_type + ',' + sn_phone_type
from persontable where name = 'Bill'

select @.foo

or something like that.

No comments:

Post a Comment