Michele
The removal or change of the meta data should not be a coding task. You shouldn't fiddle directly with meta data in SQL as this can cause problems. I hope you have a backup of your system.
The error message you are experiencing in the SQL are referential integrity messages.
An old but still useful article is this one: community.sagecrm.com/.../quot-insights-quot-into-meta-data.aspx
This article links to other that start to explain the role of meta data.
I should have stressed that once you have found that there were some items of meta data related to the custom entity you would need to carry out the changes in the interface.
A system administrator should be able to make all the changes needed through the Sage CRM admin screens.
The different meta data table hold definitions of the different structures.
Custom_screenobjects defines the 'header' record for tabs groups, screens and lists.
Custom_screens defines the fields included in screens
Custom_lists defines the columns included in lists
Custom_tabs defines the options defined in the tab menus.
Custom_edits defines the properties of fields e.g. entry type
The removal of the custom table would be the reverse in which a component add elements. This can be done in the different admin areas
1.Translations that have been added or updated
Administration -> Customization -> Translations
2.Workflows that have been added or updated
Administration -> Advanced Customization -> Workflow
Administration -> Advanced Customization -> Escalation
3.Reports that have been added or updated
User reports area
4.Table level scripts that have been added or updated
Administration -> Customization -> CustomEntity - TableScripts tab
5.Container Block items that have been added or updated
Administration -> Customization -> CustomEntity - Blocks tab
6.Tab groups that have been added or updated
Administration -> Customization -> CustomEntity - Tabs tab
7.Fields on screens that have been added or updated
You will have to go into each of the children of the Custom Entity and remove the foreign key reference from the screens. For example if the CustomEntity has Companies then you would need to go to
Administration -> Customization -> Company - Screens tab
Then look into each screen to remove the reference to the Custom Entity
8.Lists/Grids that have been added or updated
Administration -> Customization -> CustomEntity - Lists tab
9.Screen Objects that have been added or updated
Administration -> Customization -> CustomEntity - Screen tab
10.Columns that have been added or updated
You will have to go into each of the children of the Custom Entity and remove the foreign key field from the system. For example if the CustomEntity has Companies then you would need to go to
Administration -> Customization -> Company - Fields tab
11.Views that have been added or updated
Administration -> Customization -> CustomEntity - Views tab
12.Tables that have been added or updated
Administration -> Advanced Customization -> Tables and Databases
13.Database links that have been added or updated
This only needs to be done if the new entity exists in an external database and the link is not used by any other table.
Administration -> Advanced Customization -> Tables and Databases