sql server - Enforce link tables -
i have 2 tables, 1 called season other 1 episode. between them link table stores seasonid , episodeid. how make sure when new episode added link table updated well?
assuming using sql service. can achieve of trigger this
query
create trigger trig_update_episode on [episode] insert begin if not exists (select 1 [dbo].[tblepisodesession] (nolock) [episodeid] = [inserted.id]) print n'you must update entry in tblsessionepisode well'; end
for both table should create trigger given above.
in example query can replace message actual query should create entry in tblepisodesession.
hope helps.
Comments
Post a Comment