i guess you need something like this
Assume that you are connected to DestinationDataBase then
insert TableB
select * from TargetDataBase.dbo.TableA
and if not in DestinationDataBase then
insert DestinationDataBase.dbo.TableB
select * from TargetDataBase.dbo.TableA</pre>