Import Excel Sheet to a SQL Table

Navinkumar Kanagaraj 96 Reputation points
2022-05-18T10:08:11.79+00:00

HI,

Here I am trying to import excel data to sql table. But I could see that Based on the no of rows present in the Database table, It is providing as much null values.

If suppose, I am having the table name Car in DB. If I try to import Data to the same Table where I have the Additional Data in the excel file and it Consists of only 5 rows. I Could see that after importing, there are 18 rows total and where 4 rows consisting full of Null values.

How to avoid this when importing itself.

Please Help me out. Thanks.

SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,702 questions
SQL Server | Other
0 comments No comments
{count} votes

Accepted answer
  1. Olaf Helper 47,436 Reputation points
    2022-05-18T10:38:56.383+00:00

    That's not really a SQL Server problem, that's how Excel works.
    Once you touch a cell Excel think you entered it and on import you get that rows as well.

    Delete the unwanted rows after import.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. ZoeHui-MSFT 41,491 Reputation points
    2022-05-19T01:49:22.16+00:00

    Hi @Navinkumar Kanagaraj ,

    Are you using SSIS to load the data to the table?

    If yes, you may use sql command when using excel source to load data, and the you can remove the null values.

    select Id,name from [sheetname$]  
      
    where Id is not null  
    

    Or you may use Conditional Split, check here.

    Regards,

    Zoe


    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".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

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.