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 -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -