Ms CRM and SQL

  • Hi we are having a really hard time determining the right corse of action to take with our MS CRM project. Basically we have a MS CRM system setup and fully functioning. The problem that we face is that an outsourced party built external SQL tables that record Interest and Benefit information . When a specific delete is made in the CRM system on this Benefit and Interest data,, the delete is being made based on the BenefitTypeId colum. We need to find a way to delete based on a unique id /index??Here is all of the information that I think is needed please let me know if I can provide additional information to assit in the resolution of this problem.sincerely Ryan ShawnegoI am trying to alter or if need be create a trigger that will delete just one row out of a table. There are two tables involved, one called Benefits and the other called BenefitsType. Benefits has 9 columns.1.AccountId - Primary Key - Uniqueidentifier2.BenefitTypeId - int - primary key3.Unique_Id - int- primary key4.BenefitsExtraContact - varchar5.BenefitsComments - varchar6.BenefitsDate - datetime7.ContactId - uniqueidentifie8.BenefitName - varchar9.BenefitValue  - money The BenefitType has two columns.1.BenefitTypeId - Primary key2.BenefitDescription - varcharThere are 16 Benefit Types with a description on each. The current delete trigger is in the benefittype table. What happens when you select delete on the web page, it will delete all benefit types of say 2.  Would like it to just delete one row of the benefit type number 2 instead of all them.  See trigger below.create trigger tD_U_BenefitType on U_BenefitType for DELETE as/* MMC Builtin Sun Feb 25 11:12:06 2003 *//* DELETE trigger on U_BenefitType */begin  declare  @errno   int,           @errmsg  varchar(255)    /* MMC Builtin Sun Feb 25 11:12:06 2003 */    /* U_BenefitType R/12 U_Benefits ON PARENT DELETE RESTRICT */    if exists (      select * from deleted,U_Benefits      where        /*  U_Benefits.BenefitTypeId = deleted.BenefitTypeId */        U_Benefits.BenefitTypeId = deleted.BenefitTypeId    )    begin      select @errno  = 30001,             @errmsg = 'Cannot DELETE U_BenefitType because U_Benefits exists.'      goto error    end    /* MMC Builtin Sun Feb 25 11:12:06 2003 */    returnerror:    raiserror @errno @errmsg    rollback transactionendWould greatly appreciate any help on this. ryan_shawnego@yahoo.com.
  • Please do not duplicate post. Go back and edit when you run into an issue such as the contiuoius string.

    See/Leave replies in http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=9&messageid=102401

  • Hello again, thank you for your help. I will not do duplicate post any more. I am still figuring this thing out.

    I want to delete based on what the user selects from a datagrid control on an asp form in ms crm. right now the delete is causing all like types to be deleted that correspond to the desired delete type.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply