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

swift - Button on Table View Cell connected to local function -

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

c# - ajax - How to receive data both html and json from server? -