Query about select statement for insert missing records

Hello,

I want to detect the missing recordings in a table of destination by means of a select minus or where not in  but tables have no same structure and I shall wish to insert what misses:

insert into dbtarget.schematarget.table
select * ,
(
select name
From [ serversource ] .dbsource.sys.schemas
Objectpropertyex (object_id (' 01A.ACES ') where schema_id = ', SchemaId ')
) as folder from  [serversource] .dbsource.01A.ACES
Minus
select  * from dbtarget.schematarget.table where [ folder ] = ' 01A '

How can do this, do you have an example?
Thanks
bibi
bibi92Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Nathan RileyFounderCommented:
insert into dbtarget.schematarget.table
select * ,
(
select name
From [ serversource ] .dbsource.sys.schemas
Objectpropertyex (object_id (' 01A.ACES ') where schema_id = ', SchemaId ')
) as folder from  [serversource] .dbsource.01A.ACES
where name not in
(select name from dbtarget.schematarget.table where [ folder ] = ' 01A ')

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bibi92Author Commented:
but the target table doesn't have the same structure. thanks regards bibi
Nathan RileyFounderCommented:
what are the columns in the target table?
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

bibi92Author Commented:
folder, it's the reason for that I add select name
From [ serversource ] .dbsource.sys.schemas
Objectpropertyex (object_id (' 01A.ACES ') where schema_id = ', SchemaId ')
 and a column in a source table has for name rowid and in the target table drowid.
Thanks
bibi
SharathData EngineerCommented:
Didn't get you exactly. Could your explain with some sample data?
bibi92Author Commented:
I think I can create a temp table for add schema name and following do

insert into dbtarget.schematarget.table
select s.[ROW], o.[ROWID_0] from stmt_repl s
INNER JOIN ods.ODS.GAC o
on s.[ROW]=o.[ROWID_0]
and o.[DOS_0] = '01A'
where s.[ROW]  not in (select o.ROWID_0 from  ods.ODS.GAC)
Thanks
bibi
bibi92Author Commented:
from this example, I can write query after creating a table temp thanks bibi
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.