How to undeploy a BAM Schema after you lost the right Excel sheet
If you make an BAM Excel sheet and deploy it, you either need that same Excel sheet or it's exported XML to undeploy it. What happened to me two times now, is that I changed the sheet and it's XML export, before I undeployed it.
Now, when I try to deploy the new version, I get an “The activities and/or views have already been deployed. Please undeploy first before redeploying.”
And when I try to undeploy using the new version, I get an “BAM undeployment failed. The view MainView cannot be undeployed. The definition does not match.”
The solution to this is pretty simple. The definition you used to deploy the earlier schema is stored in the table bam_Metadata_Transactions in the BAMPrimaryImport database. Find the last record with deploy in the optype column and the correct filename in the BamDefFileName column. Copy the contents of the BAMDefinitionXML column to a textfile, save it as something.xml and use that file to undeploy your BAM Schema.
Note: The XML can get quite large and if that happens, you can not get the complete XML using the Query Analyzer or the Enterprise Manager. I used Access to attach to the table and get the correct XML.