Hi,
Please try this
Create Procedure test_Sp
As
Begin
insert into Test
select a.Name,b.sub from
IdTable b join Nametable a ON b.no = a.no
where b.no like 'x_%' end
Also i have create one sample for it like,
Create table #IdTable([No] varchar(10),Name varchar(20))
Insert into #IdTable values('11111','AA')
Insert into #IdTable values('22222','BB')
Insert into #IdTable values('33333','CC')
Insert into #IdTable values('44444','DD')
Insert into #IdTable values('55555','EE')
Create table #Nametable(ID bigint, [No] varchar(10),sub varchar(20))
Insert into #Nametable values(1,'11111','A1')
Insert into #Nametable values(2,'22222','B1')
Insert into #Nametable values(3,'11111','A2')
Insert into #Nametable values(4,'22222','B2')
Insert into #Nametable values(5,'33333','C1')
Create Table #Test (Name varchar(20),Sub varchar(20))
insert into #Test
select a.Name,
b.sub
from #Nametable b join #IdTable a ON b.no = a.no where b.no like '1%'
select * from #Test
Drop table #IdTable
Drop table #Nametable
Drop table #Test