Share via

SQL database

Anonymous
2024-08-09T07:23:05+00:00


Hello, I've just started learning SQL. I created new tables and while trying to define relationships between some tables, I received an error like the one in the attachment. I checked it a few times and everything looks normal. I couldn't find a solution because I was new. Can you help?

Microsoft 365 and Office | Access | Other | Other

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

George Hepworth 22,855 Reputation points Volunteer Moderator
2024-08-09T12:17:47+00:00

When you create a relationship on two tables, the fields involved in the relationship must be of the same datatype.

In this case, the "ID" field in Countries is, most likely, an Integer and designated as an Identity field and also designated as the Primary Key for the Countries table. Is that correct? That's the typical expectation here.

In this case, where you want to create a relationship on the "CountryID" field in Cities, CountryID must also be an Integer.

If you used some other datatype for "ID" in Countries, of course, the "CountryID" field in Cities must be that same datatype. That would be less common, but possible.

Note that this forum supports MS Access. SQL Server is often used as the backend for Access applications. When you link to the SQL Server tables from Access, the Integer datatype will be interpreted as Long Integer.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

Answer accepted by question author

Anonymous
2024-08-09T09:59:37+00:00

Hello bahar gökgöz,

Good day!!

This community is geared more towards to general and built-in feature queries in Microsoft Access application.

Since your question is about SQL database, to make sure you get the dedicated assistance, I sincerely recommend you post your concern to the dedicated channel Microsoft Q&A Community with SQL Server tag: SQL Server - Microsoft Q&A Members and engineers over there are proficient in the knowledge of SQL queries. They will focus on the specific situation and provide specific suggestions for you.

In the meanwhile, we will also keep this thread open. Welcome community members and MVPs who have similar experience to share suggestions here.

Thanks for your cooperation and understanding! Have a nice day!

Best regards,

Tina

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2024-08-13T05:00:28+00:00

    Hi, thank you for keeping my post here. I received a suggestion that solved my problem and it was solved. thanks.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2024-08-13T04:58:33+00:00

    HI, I changed the data type and my problem was solved. Thank you very much for your simple but useful suggestion.

    Was this answer helpful?

    0 comments No comments