The membership model allows you to create custom fields for your members, this means that each piece of information will be stored in it's own row, allowing you to add as much information as you like.
So for our example, our members contain custom data of:
- First Name
- Last Name
This is stored in the CMSPropertyData and the CMSPropertyType tables.
So down to business....
You need to use SQLs Pivot method.
,CAST(COALESCE(pd.dataNVarchar,pd.datantext) AS VARCHAR(1000)) AS [value]
,pt.Name as [columnname]
FROM cmsMember m
JOIN cmsPropertyData pd
ON m.nodeId = pd.contentNodeId
JOIN cmsPropertyType pt
ON pt.id = pd.propertytypeid
FOR columnname in (salutation,firstname,lastname,telephone,address
It's as simple as that. Just replace the columns with the name of your columns.