Skip to content Skip to sidebar Skip to footer

Sql Server Trigger Insert Values From New Row Into Another Table With Many-to-many Relationship

I have three tables: tbl_profiles tbl_options tbl_profileOption with many-to-many relationship what the insert trigger on tbl_options I have to use to add the new options to ea

Solution 1:

thank for all who try to help me... I got the solution

  • first trigger on tbl_option

    goCreateTRIGGERinsertProfileToOptionONdbo.tbl_optionsAFTERINSERTASinsertintotbl_profileOption (profileOption_profileId,
      profileOption_optoinId)
    (select tbl_profiles.profile_id, @@IDENTITY from tbl_profiles)
    
  • second trigger on tbl_profile

    goCreateTRIGGERinsertOptionToProfileONdbo.tbl_profilesAFTERINSERTASinsertintotbl_profileOption (profileOption_profileId,
      profileOption_optoinId)
    (select @@IDENTITY, tbl_options.option_id from tbl_options)
    

if there is another solution this will be good, thank you

Post a Comment for "Sql Server Trigger Insert Values From New Row Into Another Table With Many-to-many Relationship"