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

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

dns - Dokku server hosts two sites with TLD's, both domains are landing on only one app -

Delphi 7 and decode UTF-8 base64 -