Skip to content
Advertisement

Duplicate entries based on values in key/value pair table in SQL Server

I have a key/value pair table

If you see the 113565 and 113545 materials are having the same characteristics and characteristic_value. According to our business rules, no two materials should be having the same characteristics and characteristic_value. And in my real case scenario, materials sometimes will be having nearly 1000 characteristics.

please help me to get the bad records identified.


I tried making the rows into columns using this query but this is resulting in more than 1300 columns and I am not sure how to proceed after this

Advertisement

Answer

The simplest method is string_agg():

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement