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

2
  • Can you put screen shot of your file for example just with 2-3 product data. Commented Aug 7, 2018 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 Commented Aug 7, 2018 at 12:55

1 Answer 1

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);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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