Reorganizing fields in data extension

It is impossible via the UI to change the order of the fields in a Data Extension unless you delete fields and add them again or utilize a SQL query to create a new DE with the correct field layout.

There is a way via the SOAP API to view the ordinal value of an existing Data Extension Field - which you can then look to update via an Update request to the DataExtension Object. This is the best option I have been able to find so far.

I have attempted this on my own without much success, but wanted to pass along what I know in case you are able to break through it.

To reiterate, there will be 2 steps:

  1. Retrieve Request to DataExtensionField Object to get the info for each field
  2. Update Request to DataExtension Object to update the ordinal values for each field.

Sample SOAP for Update Call:

<soapenv:Body>
        <UpdateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
            <Options /> 
            <Objects xsi:type="ns1:DataExtension" xmlns:ns1="http://exacttarget.com/wsdl/partnerAPI">
                <CustomerKey>yourExternalKey</CustomerKey> 
                <Fields>
                    <Field>
                        <Name>yourField</Name> 
                        <Ordinal>2</Ordinal> 
                        <IsRequired>true</IsRequired> 
                    </Field>
                </Fields>
            </Objects>
        </UpdateRequest>
    </soapenv:Body>

If someone still searching (like me). I'm almost certain that is not possible without recreating the Data Extension.

I have tried with WSProxy (tried something similar to Ivan's code snippet). Even though, I got an "Ok" Status as response, the fields stayed the same.

I had opened a case and support told me that Ordinal property is not updatable through SOAP API (therefore, neither using WSProxy). It's possible to check If you make a describe call on the "DataExtensionField" object. Support also told me that:

" The “OK” message you are seeing means that the server received your request. The error is occuring after the API call is complete, so it does not get flagged by the call.

Ordinals are created at the same time as the Data Extension and are not meant to be updated as this could break the DE. If the ordinals on a Data Extension need to be changed, best practice would be to recreate that Data Extension. "