--这个完全可以用一个语句来完成UPDATE r_PersonReport
SET
Practitioner =isnull(B.Practitioner,0),
RealPerson =isnull(B.RealPerson,0),
TempPerson =isnull(B.TempPerson,0),
Technician =isnull(B.Technician,0),
AdvPerson =isnull(B.AdvPerson,0),
MidPerson =isnull(B.MidPerson,0),
PriPerson =isnull(B.PriPerson,0),
OtherPerson =isnull(B.OtherPerson,0),
RegPerson =isnull(B.RegPerson,0),
RegJls =isnull(B.RegJls,0),
RegJzhs =isnull(B.RegJzhs,0),
RegGcs =isnull(B.RegGcs,0),
RegJzs =isnull(B.RegJzs,0),
RegZjs =isnull(B.RegZjs,0),
RegZxs =isnull(B.RegZxs,0),
RegOther =isnull(B.RegOther,0),
Product =isnull(B.Product,0),
Gcjl =isnull(B.Gcjl,0),
Zbdl =isnull(B.Zbdl,0),
Zjzx =isnull(B.Zjzx,0),
Manager_Server =isnull(B.Manager_Server,0),
OtherPro =isnull(B.OtherPro,0)
from r_PersonReport A inner join VW_PersonInfoReport B on A.Code=B.code
where A.code in (Select Code From a_CorpZZKind)
SET
Practitioner =isnull(B.Practitioner,0),
RealPerson =isnull(B.RealPerson,0),
TempPerson =isnull(B.TempPerson,0),
Technician =isnull(B.Technician,0),
AdvPerson =isnull(B.AdvPerson,0),
MidPerson =isnull(B.MidPerson,0),
PriPerson =isnull(B.PriPerson,0),
OtherPerson =isnull(B.OtherPerson,0),
RegPerson =isnull(B.RegPerson,0),
RegJls =isnull(B.RegJls,0),
RegJzhs =isnull(B.RegJzhs,0),
RegGcs =isnull(B.RegGcs,0),
RegJzs =isnull(B.RegJzs,0),
RegZjs =isnull(B.RegZjs,0),
RegZxs =isnull(B.RegZxs,0),
RegOther =isnull(B.RegOther,0),
Product =isnull(B.Product,0),
Gcjl =isnull(B.Gcjl,0),
Zbdl =isnull(B.Zbdl,0),
Zjzx =isnull(B.Zjzx,0),
Manager_Server =isnull(B.Manager_Server,0),
OtherPro =isnull(B.OtherPro,0)
from r_PersonReport A inner join VW_PersonInfoReport B on A.Code=B.code
where A.code in (Select Code From a_CorpZZKind)
@Code定义的太短:定义长些
@Code定义的类型:最好定义成varchar型,如:Declare @code varchar(50)
变量保留上次的垃圾值