Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Problem when importing from Excel

Author  Topic 

Volkof
Starting Member

14 Posts

Posted - 2014-10-23 : 03:50:59
Hello,

I'm sure this is very simple, especially for an experience user. I have the following problem:

I imported a table with 4500 rows but SQL imported also extra 500 rows with the value NULL. The table looks like this:
ID Customer ...
4500 4501 Alex
4501 NULL NULL...
........................
Problem is that i can't change the data type, set primary key etc.
How can I solve this?

Many thanks

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-10-23 : 09:55:02
Use SSIS to do the import.
Go to Top of Page

Volkof
Starting Member

14 Posts

Posted - 2014-10-23 : 10:53:47
But is there a way to delete the NULL rows?

Thanks.
Go to Top of Page

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-10-23 : 11:05:38
sure! In SSIS, use a conditional split transformation and only send non-null rows to the destination (excel) transformation
Go to Top of Page

AASC
Starting Member

24 Posts

Posted - 2014-10-24 : 17:16:32
There is also a way to achieve this

-------------------Delete All Rows with Null
DELETE
---SELECT *
FROM TableName WHERE CustomerID IS NULL



-------------------Reset Idenity Column Value
DECLARE @MaxID INT
SET @MaxID= (SELECT MAX(CustomerID) FROM TableName)

DBCC CHECKIDENT ('dbo.TableName', RESEED, @MaxID);
Go to Top of Page
   

- Advertisement -