1

magmi : I need to import (and assign) 7000+ attribute_code Values through csv. My issue is that the format of magmi csv is Attribute names should be horizontaly column wise(7000+ cols) and values should be under.

I need to do it same like pivot or Is there is a better solution?.

Note: my data is originally stored in MS-SQL db

  • Can you put screen shot of your file for example just with 2-3 product data. – Feedlay Technologies Aug 7 '18 at 10:10
  • Here is the screen shot ibb.co/i1qL5e, I want column2 data horizontally, and column3 as it's values that means column1 will not be repeated, and I will have only two lines from the above data – Monty Nabeel Aug 7 '18 at 12:55
0

I have found a solution for the issue from the MS-SQL side. You have use Pivot Query for an unknown number of columns using STUFF Function also solved my issue,

Here is the query I did:

DECLARE @cols AS NVARCHAR(MAX),
@query  AS NVARCHAR(MAX)

select @cols = STUFF((SELECT ',' + QUOTENAME(AttrName) 
                from Attribute_View
                group by AttrName
                order by AttrName
        FOR XML PATH(''), TYPE
        ).value('.', 'NVARCHAR(MAX)') 
    ,1,1,'')

set @query = 'SELECT sku,' + @cols + ' from 
         (
            select sku, AttrName, AttrValue
            from Attribute_View
        ) x
        pivot 
        (
            max(AttrValue)
            for AttrName in (' + @cols + ')
        ) p '

execute(@query);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.