Hien Nguyen Hien Nguyen - 1 month ago 6
SQL Question

convert multi rows into multi rows with many Column and name from the first table

Please help me create the select sql in Microsoft SQL Server, i want convert from the table:

enter image description here

convert to the new table, get the distinct DeviceCode and new columns get from PartName values, and the PartName values is unlimit (DVD, Mouse, Keyboard, Monitor…..):

I just attach full image in there, with more sample data, sorry i cant add a table viewer in the post: https://farm6.staticflickr.com/5628/30615995995_a0ed8b65fa_o_d.jpg

Answer

I had a new solved detail quest in Topic:

Create dynamic select get value for column name - in SQL Server

Many thanks for the consultant Yared who help me solved this as my expected.

Best Regards, Hien Nguyen