Insert into
[PisCh].[dbo].[same_sfz] ([rensfzhm]
,[counter])
SELECT renSfzhm,COUNT(*)
FROM [pis_base_xj].[dbo].[jc_pjb]
where bdlxCode<>'70' and bdlxCode<>'81' and renSfzhm is not null
group by renSfzhm having COUNT(*)>1
insert into [PisCh].[dbo].[SfzCaculate1]
( [xzCode]
,[cunCode]
,[zuCode]
,[huCode]
,[RenName]
,[RenXbCode]
,[renCsdate]
,[renHkszdCode]
,[RenSfzhm1]
,[S2])
SELECT [xzCode]
,[cunCode]
,[zuCode]
,[huCode]
,[RenName]
,[RenXbCode]
,[renCsdate]
,[renHkszdCode]
,b.RenSfzhm
,b.bdlxCode
--,b.renhkszdsm,b.bdlxCode
FROM [PisCh].[dbo].[same_sfz] a inner join [pis_base_xj].[dbo].[jc_pjb] b
on a.rensfzhm=b.renSfzhm
--where b.rensfzhm='520102195409141224'
order by a.rensfzhm
[PisCh].[dbo].[same_sfz] ([rensfzhm]
,[counter])
SELECT renSfzhm,COUNT(*)
FROM [pis_base_xj].[dbo].[jc_pjb]
where bdlxCode<>'70' and bdlxCode<>'81' and renSfzhm is not null
group by renSfzhm having COUNT(*)>1
insert into [PisCh].[dbo].[SfzCaculate1]
( [xzCode]
,[cunCode]
,[zuCode]
,[huCode]
,[RenName]
,[RenXbCode]
,[renCsdate]
,[renHkszdCode]
,[RenSfzhm1]
,[S2])
SELECT [xzCode]
,[cunCode]
,[zuCode]
,[huCode]
,[RenName]
,[RenXbCode]
,[renCsdate]
,[renHkszdCode]
,b.RenSfzhm
,b.bdlxCode
--,b.renhkszdsm,b.bdlxCode
FROM [PisCh].[dbo].[same_sfz] a inner join [pis_base_xj].[dbo].[jc_pjb] b
on a.rensfzhm=b.renSfzhm
--where b.rensfzhm='520102195409141224'
order by a.rensfzhm