Help to find unmatched data

G

Guest

Hi

I am trying to find the best way to find unmatched data.

I have tried this below and found a few but not all unmatched data, still
having problems.

SELECT Transaktionsrader.Transaktionsrad, Transaktionsrader.Transaktionsnr
FROM Transaktionsrader LEFT JOIN Transaktionhuvud ON
Transaktionsrader.Transaktionsnr = Transaktionhuvud.Transaktionsnr
WHERE (((Transaktionhuvud.Transaktionsnr) Is Null));


Thank you in advance

Mattias
 
A

Allen Browne

What do you want when you say "unmatched"?

The query will find records in one table that have no match in the other
one. If you want the reverse as well, create another query with the join
going the other way, and the WHERE clause selecting from the other table:

SELECT Transaktionsrader.Transaktionsrad, Transaktionsrader.Transaktionsnr
FROM Transaktionhuvud LEFT JOIN Transaktionsrader ON
Transaktionhuvud.Transaktionsnr = Transaktionsrader.Transaktionsnr
WHERE Transaktionsrader.Transaktionsnr Is Null;

If you want both lots returned in one read-only query, you could UNION the
two together.
 
G

Guest

Hi

Thank you for your reply

I tried both now but still having problems here..

What I am trying to achieve here is an import of data from my Access 2003
tables in to SQL Server 2005, via SQL Server Management Studio (Import and
export wizard). All accesstables has been imported with no errors except for
this last one "Transaktionsrader"

I receive this error below:

- Copying to [MbaseMuseumServerNetSQL].[dbo].[Transaktionsrader] (Error)
Messages
Information 0x402090df: Data Flow Task: The final commit for the data
insertion has started.
(SQL Server Import and Export Wizard)

Error 0xc0202009: Data Flow Task: An OLE DB error has occurred. Error code:
0x80004005.
An OLE DB record is available. Source: "Microsoft SQL Native Client"
Hresult: 0x80004005 Description: "The statement has been terminated.".
An OLE DB record is available. Source: "Microsoft SQL Native Client"
Hresult: 0x80004005 Description: "The INSERT statement conflicted with the
FOREIGN KEY constraint "ITransaktionsrader11". The conflict occurred in
database "MbaseMuseumServerNetSQL", table "dbo.Transaktionhuvud", column
'TransaktionhuvudTransaktionsnr'.".
(SQL Server Import and Export Wizard)

Information 0x402090e0: Data Flow Task: The final commit for the data
insertion has ended.
(SQL Server Import and Export Wizard)

Error 0xc0047022: Data Flow Task: The ProcessInput method on component
"Destination - Transaktionsrader" (115) failed with error code 0xC0202009.
The identified component returned an error from the ProcessInput method. The
error is specific to the component, but the error is fatal and will cause the
Data Flow task to stop running.
(SQL Server Import and Export Wizard)

Error 0xc0047021: Data Flow Task: Thread "WorkThread0" has exited with error
code 0xC0202009.
(SQL Server Import and Export Wizard)




Mattias
 
A

Allen Browne

Those are SQL Server messages, not Access messages, I take it?

You might get some help with those in the SQL Server group.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Mattias said:
Thank you for your reply

I tried both now but still having problems here..

What I am trying to achieve here is an import of data from my Access 2003
tables in to SQL Server 2005, via SQL Server Management Studio (Import and
export wizard). All accesstables has been imported with no errors except
for
this last one "Transaktionsrader"

I receive this error below:

- Copying to [MbaseMuseumServerNetSQL].[dbo].[Transaktionsrader] (Error)
Messages
Information 0x402090df: Data Flow Task: The final commit for the data
insertion has started.
(SQL Server Import and Export Wizard)

Error 0xc0202009: Data Flow Task: An OLE DB error has occurred. Error
code:
0x80004005.
An OLE DB record is available. Source: "Microsoft SQL Native Client"
Hresult: 0x80004005 Description: "The statement has been terminated.".
An OLE DB record is available. Source: "Microsoft SQL Native Client"
Hresult: 0x80004005 Description: "The INSERT statement conflicted with
the
FOREIGN KEY constraint "ITransaktionsrader11". The conflict occurred in
database "MbaseMuseumServerNetSQL", table "dbo.Transaktionhuvud", column
'TransaktionhuvudTransaktionsnr'.".
(SQL Server Import and Export Wizard)

Information 0x402090e0: Data Flow Task: The final commit for the data
insertion has ended.
(SQL Server Import and Export Wizard)

Error 0xc0047022: Data Flow Task: The ProcessInput method on component
"Destination - Transaktionsrader" (115) failed with error code 0xC0202009.
The identified component returned an error from the ProcessInput method.
The
error is specific to the component, but the error is fatal and will cause
the
Data Flow task to stop running.
(SQL Server Import and Export Wizard)

Error 0xc0047021: Data Flow Task: Thread "WorkThread0" has exited with
error
code 0xC0202009.
(SQL Server Import and Export Wizard)




Mattias

Allen Browne said:
What do you want when you say "unmatched"?

The query will find records in one table that have no match in the other
one. If you want the reverse as well, create another query with the join
going the other way, and the WHERE clause selecting from the other table:

SELECT Transaktionsrader.Transaktionsrad,
Transaktionsrader.Transaktionsnr
FROM Transaktionhuvud LEFT JOIN Transaktionsrader ON
Transaktionhuvud.Transaktionsnr = Transaktionsrader.Transaktionsnr
WHERE Transaktionsrader.Transaktionsnr Is Null;

If you want both lots returned in one read-only query, you could UNION
the
two together.
 
J

John Spencer

Normally that error message means that you are trying to add a record to the
table Transaktionsrader that has an invalid value in the foreign key field that
links to the table dbo.Transaktionhuvud.

It could be that the relationship is set up to not allow nulls in the foreign
key. Or you could have an invalid value in one (or more) of the records.
Hi

Thank you for your reply

I tried both now but still having problems here..

What I am trying to achieve here is an import of data from my Access 2003
tables in to SQL Server 2005, via SQL Server Management Studio (Import and
export wizard). All accesstables has been imported with no errors except for
this last one "Transaktionsrader"

I receive this error below:

- Copying to [MbaseMuseumServerNetSQL].[dbo].[Transaktionsrader] (Error)
Messages
Information 0x402090df: Data Flow Task: The final commit for the data
insertion has started.
(SQL Server Import and Export Wizard)

Error 0xc0202009: Data Flow Task: An OLE DB error has occurred. Error code:
0x80004005.
An OLE DB record is available. Source: "Microsoft SQL Native Client"
Hresult: 0x80004005 Description: "The statement has been terminated.".
An OLE DB record is available. Source: "Microsoft SQL Native Client"
Hresult: 0x80004005 Description: "The INSERT statement conflicted with the
FOREIGN KEY constraint "ITransaktionsrader11". The conflict occurred in
database "MbaseMuseumServerNetSQL", table "dbo.Transaktionhuvud", column
'TransaktionhuvudTransaktionsnr'.".
(SQL Server Import and Export Wizard)

Information 0x402090e0: Data Flow Task: The final commit for the data
insertion has ended.
(SQL Server Import and Export Wizard)

Error 0xc0047022: Data Flow Task: The ProcessInput method on component
"Destination - Transaktionsrader" (115) failed with error code 0xC0202009.
The identified component returned an error from the ProcessInput method. The
error is specific to the component, but the error is fatal and will cause the
Data Flow task to stop running.
(SQL Server Import and Export Wizard)

Error 0xc0047021: Data Flow Task: Thread "WorkThread0" has exited with error
code 0xC0202009.
(SQL Server Import and Export Wizard)


Mattias

Allen Browne said:
What do you want when you say "unmatched"?

The query will find records in one table that have no match in the other
one. If you want the reverse as well, create another query with the join
going the other way, and the WHERE clause selecting from the other table:

SELECT Transaktionsrader.Transaktionsrad, Transaktionsrader.Transaktionsnr
FROM Transaktionhuvud LEFT JOIN Transaktionsrader ON
Transaktionhuvud.Transaktionsnr = Transaktionsrader.Transaktionsnr
WHERE Transaktionsrader.Transaktionsnr Is Null;

If you want both lots returned in one read-only query, you could UNION the
two together.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top