如何使用内部联接更新2个表 [英] how to update 2 tables using inner join

查看:75
本文介绍了如何使用内部联接更新2个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hii ..所有

i想要使用内部联接更新2个表中的数据..

我的sp是..任何给我的想法abt它的语法..它是是否正确..





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..


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 + '';

推荐答案

在SQL2008中,您无法一次更新两个表。



如果您需要了解OUTPUT子句中的更新内容。
In SQL2008 you cannot update two tables at once.

If you need to know what was updated in one look at the OUTPUT clause.


这篇关于如何使用内部联接更新2个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆