The columns Status and YYY are either duplicated or not in a sequence. Each column can only be selected one time, and columns must be selected in sequence. (wcf-custom adapter)

This error occurred on the production environment of a customer when using a view and the wcf-custom adapter with sql-binding.


<ns0:NACK Type="NACK" xmlns:ns0="http://schema.microsoft.com/BizTalk/2003/NACKMessage.xsd">
<NAckID>{D3B42630-4221-4B76-9E55-9B148D4A8C7B}</NAckID>
<ErrorCode>0xc0c0167a</ErrorCode>
<ErrorCategory>0</ErrorCategory>
<ErrorDescription>Microsoft.ServiceModel.Channels.Common.XmlReaderGenerationException: The columns A and B are either duplicated or not in a sequence. Each column can only be selected one time, and columns must be selected in sequence.
at Microsoft.Adapters.Sql.SelectBodyWriter.OnWriteBodyContents(XmlDictionaryWriter writer)
at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfMarshaller.CreateBizTalkMessageStream(Message wcfMessage, IAdapterConfigInboundMessageMarshalling config, TLConfig tlConfig, RLConfig rlConfig)
at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfMarshaller.CreateBizTalkMessage(IBaseMessageFactory messageFactory, IAdapterConfigInboundMessageMarshalling marshallingConfig, Message wcfMessage, TLConfig tlConfig, RLConfig rlConfig)
at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.RequestCallback(IAsyncResult result)</ErrorDescription>
</ns0:NACK>

The first solution after googling was to define the columns in the request xml so the order is explicit as stated in Sandro’s blog. This resulted in the same error. Connecting the staging environment to the production server gave no errors, and connecting BizTalk production to the staging database again gave the same error.

Only the production machine gave the error….

For BT2013r2 this was a known issue: “FIX: The element orders in the schema generated by WCF-SQL adapter are different for SQL Server 2012 and SQL Server 2014

After some digging we noticed that the CU1 was installed on all environments except…… the production… After installing there were no more problems with the column order. So if you encounter this problem check if the CU is installed correctly.

cu1 2013 r2

Find more info about the CU here.

How to recursively delete files but keep the directory structure through the Windows command prompt?

Note to myself:
forfiles /p D:Archive /s /c “cmd /c IF @isDir EQU FALSE (del /Q /F @file)”

forfiles parameters:
/p -> Path in which the forfiles command will search for files.
/s -> Orders the forfiles command to execute recursively in all subdirectories.
/c -> Command to execute for each file found by forfiles. The command must be in quotes and start with cmd /c.

Or in powershell:
Get-ChildItem -Path d:test -Recurse -Force | Where-Object { -not ($_.psiscontainer) } | Remove-Item –Force

Got this from here. Thanks Francois.