Click here to Skip to main content
15,900,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have two table tblOrder and Tblaccount.
every order record has an Account Details
in tblorder i have orderID which is PK field and Auto-increment as well
in tblaccount i have OrderID which Fkey which is not Auto-increment and referring to tblorder
So when i Place an order there must be value save in tblcount orderID field same as OrderID in tblorder.
Posted
Updated 29-Jan-14 5:59am
v2
Comments
Aravindba 28-Jan-14 5:20am    
hai
PK,FKey are just referring,that one not save data,i mean if u refer FKey,that key is related to PK,so it simply refer that Parent Key,if u save in tblorder it not save in tblaccount,u need to save in tblaccount also

You can use an after trigger on insert on table tblorder.
 
Share this answer
 
Comments
abdul manan 7 29-Jan-14 0:30am    
How i don't understand ?
DotnetCoders001 30-Jan-14 13:23pm    
Did you find a solution to your query or still stuck?
abdul manan 7 31-Jan-14 2:12am    
yes i found thanks
DotnetCoders001 31-Jan-14 5:08am    
Can you please share the approach you took to solve your problem?
abdul manan 7 31-Jan-14 5:15am    
insert into tblaccount(clientId,orderId,totalAmount,amountRece,amountBal) values(@clientid,(select Top 1 tblorder.orderId from tblorder ORDER BY tblorder.orderId DESC),@totalamount,@amountrec,@balnce)
insert into tblaccount(clientId,orderId,totalAmount,amountRece,amountBal) values(@clientid,(select Top 1 tblorder.orderId from tblorder ORDER BY tblorder.orderId DESC),@totalamount,@amountrec,@balnce)
SQL

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900