February 10, 2009 at 7:13 am
Hi all,
How do I make sure that when I create a record in a table that at least one record is created in a related table?
Table A has a Pk and Table B has a foreign key to table A. When I add a record in table A, I want to make sure that at least one corresponding record is created in table B. Do I perhaps use a trigger for this?...
February 10, 2009 at 7:33 am
It depends on how much control you have over the inserts. If all calls to your tables are through stored procedures, just add a second insert to the procedure so that data is added to both tables. If you don't have that level of control, a trigger is a good solution.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
February 10, 2009 at 9:09 am
Hi
You want to create a dummy in Child table for every row that you insert into Parent table? what is the use of this?? do you want to avoid Outer-joins??
Thanks
Vijaya Kadiyala
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply