Click here to Skip to main content
15,889,876 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hii.. all
i want to update data in 2 tables using inner join..
my sp is.. any give me idea abt it's syntax.. it's correct or not..


SQL
SET @vQuery = 'update Child,Family SET Child.cname=@Chld_Name,Child.distt=@distic,Child.block=@block,Child.gpmctc=@GP,Child.village=@village,
   Child.habitation=@habitation,Child.sex=@SEX,Child.dob=@DOB,Family.pincode=@Pincode,Family.hhno=@House_no,Family.fname=@Father,
   Family.mname=@Mother,Family.gname=@Guardian,Family.social_grp=@social_grp,Family.minority=@Minority,Family.total_male=@Male,Family.total_fema=@Female,
   Family.seasonal_m=@seasnal_mgrtn,Family.migration_=@Mgrtn_Type,Family.duration=@durtn_Mgrtn,Family.lp=@LP,Family.up=@UP,Family.sec=@SEC,
   Family.catch_s_lp=@Ctchmnt_LP,Family.catch_s_up=@Ctchmnt_UP,Family.catch_s_se=@Ctchmnt_SEC,Child.location=@location,
Child.residing=@residing,Child.mother_ton=@mother_ton,Child.disability=@Disblty_type,Child.sch_code=@Schl_CODE,Child.class=@CLASS,
Child.nereason=@NEREASON,Child.droupout=@DRPOUT_rsn,Child.highclass=@HIGH_class
FROM ' + @ChildTblName + ' As Child  WITH (NOLOCK) INNER JOIN ' + @FamilyTblName + ' AS Family WITH (NOLOCK) ON
Child.barcode=Family.barcode WHERE LTRIM(RTRIM(Child.cname)) <> '''' AND Child.distt = ' + @DistrictID + '';
Posted
Comments
bindash 11-Mar-14 3:16am    
PLEASE give me idea.. how i will update 2 tables in one stored procrdure
thanks in advance..

1 solution

In SQL2008 you cannot update two tables at once.

If you need to know what was updated in one look at the OUTPUT clause.
 
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