update A set ID=B.IDType+B.IDNo from A inner join B ON A.Mobile=B.Mobile and B.IDType<>'' and B.IDNo<>'' and not B.IDType is null and not B.IDNo is null
update a.id=b.idtype+idNo where a.mobile=b.mobile and b.idtype<>'' and b.idNo<>''
create procedure as begin update a set id=(b.idtype+b.idno) from a,b where b.mobile in (select mobile from a) end;
update a set a.id=b.idtype+b.idNo from b where a.mobile=b.mobile and b.idtype<>'' and b.idNo<>'' 刚才写错了
上面我写错了 create procedure as begin update a set id=(b.idtype+b.idno) from a,b where b.mobile in (select mobile from a) and b.idtype is not null and b.idno is not null end;
update A set [ID]=B.IDType+B.IDNo from A inner join B on A.Mobile=B.Mobile where B.IDType is not null and B.IDNo is not null
update a set a.ID=b.IDType + b.IDNo from A a,B b where a.mobile = b.mobile and b.IDType is not null and b.IDNo is not null and b.IDType <>'' and b.IDNo <>''
create proc A_B as begin declare @number char(16),@id_type char(4),@id_no char(20) declare @id char(24) declare B_cursor cursor for select id_type,id_no,mobile from B open B_cursor fetch next from B_cursor into @id_type,@id_no,@number while @@fetch_status = 0 begin if exists (select 1 from A where mobile = @number) begin if len(@id_type) > 0 and len(@id_no) > 0 begin @id = ltrim(rtrim(@id_type) + ltrim(rtrim(@id_no) update A set id = @id where mobile = @number end end fetch next from B_cursor into @id_type,@id_no,@number end close B_cursor deallocate B_cursor end
and B.IDType<>'' and B.IDNo<>'' and not B.IDType is null and not B.IDNo is null
as
begin
update a
set id=(b.idtype+b.idno)
from a,b
where b.mobile in (select mobile from a)
end;
刚才写错了
create procedure
as
begin
update a
set id=(b.idtype+b.idno)
from a,b
where b.mobile in (select mobile from a) and b.idtype is not null and b.idno is not null
end;
set [ID]=B.IDType+B.IDNo
from A
inner join B
on A.Mobile=B.Mobile
where B.IDType is not null and B.IDNo is not null
from A a,B b
where a.mobile = b.mobile and b.IDType is not null and b.IDNo is not null and b.IDType <>'' and b.IDNo <>''
begin
declare @number char(16),@id_type char(4),@id_no char(20)
declare @id char(24)
declare B_cursor cursor for
select id_type,id_no,mobile from B
open B_cursor
fetch next from B_cursor into @id_type,@id_no,@number
while @@fetch_status = 0
begin
if exists (select 1 from A where mobile = @number)
begin
if len(@id_type) > 0 and len(@id_no) > 0
begin
@id = ltrim(rtrim(@id_type) + ltrim(rtrim(@id_no)
update A set id = @id where mobile = @number
end
end
fetch next from B_cursor into @id_type,@id_no,@number
end
close B_cursor
deallocate B_cursor
end