Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 4729

Insert keys in Master and Detail Tables

$
0
0

All

I have two tables=

Master table

id_master, int, Autoincremental

detail_table

id_master

id_detail,int Autoincremental

My question is, in the detail table, how create a table that the id_detail start in 1, when a id_master is new?

Example

Master_table

id_master

1

2

3

detail_table

id_master         id_detail

1                          1

1                           2

1                          3

2                           1

2                             2

3                           1


How do I do it every time a new id is added in the "master" start of 1 in the "detail"?


Viewing all articles
Browse latest Browse all 4729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>