Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

Inserting master detail table records in a single query in sql server 2008

$
0
0

Friends,

I have to insert 1200 records in the master detail table directly.

i have written 2 separate queries to insert records in the master and detail table.

insert into student_receipt
(pre_vocdt,pre_cbcode,pre_customer,pre_amount,pre_narrat,pre_astatus)
values
('20141014','1001','14TAP001',20000,'Tuition Fees','S')

in the above student_receipt table..pre_vocno is autoincrement...

i want to insert that value in the below table (student_receipt_detail) and also i want to make it as a single query...

insert into student_receipt_detail
(prd_vocno,prd_sno,prd_billno,prd_glcode,prd_amount)
values
(101,'1','1','3010101',20000)

the static values in master table is pre_vocdt,pre_cbcode,pre_amount,pre_narrat and pre_astatus

the static values in detail table is prd_sno,prd_billno,prd_glcode,prd_amount

the prd_vocno should have the same value as the pre_vocno of master table (autoincrement field)

thanks


Viewing all articles
Browse latest Browse all 8428

Trending Articles



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