I’ve got a table in database that looks like this:
CustomerId Attribute Value
================================
30 Name John
30 Surname Smith
30 Phone 555123456
to make some use of the data I need to make it look sth. like this:
CustomerId Name Surname Phone
======================================
30 John Smith 555123456
I know I can create stored procedure or table-valued function that will do it for me, but I’m wondering what would be the best choice here? Maybe I can do it with some clever sql select query only?
If this is SQL Server 2005 or later, you can use
PIVOT:Or a solution that does not use
PIVOT: