can we merge one to one table in sql server?

Farshad Valizade 501 Reputation points
2024-08-11T02:50:42.02+00:00

hi

I have this data in excel.now I have created two tables in the sql server one for left side of my data and one for last column (TpNo).

FinId is my primary key in both table.

one TpNo has one FinId but each fin has not a TpNo some of them has and some of them has not.

now my question is can I merge two tables in on table to reduce join in my query?

3

1

2

SQL Server Other
0 comments No comments
{count} votes

Accepted answer
  1. Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
    2024-08-11T09:03:34.68+00:00

    From what you have said, yes, you can make that into one table. Since TpNo is not available for all FinId, you would need to make the column TpNo nullable.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. LiHongMSFT-4306 31,566 Reputation points
    2024-08-12T01:57:50.6533333+00:00

    Hi @Farshad Valizade

    can I merge two tables in on table

    Yes, since you have FinID in both tables.

    However, why not just import the whole excel file to another new table?

    Best regards,

    Cosmog


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.