Problem w/ Nulls: Import Excel 2002 -> SQL Server 2000

I am attempting to import 6 worksheets from Excel to 6 tables in SQL Server 2000.  When the package executes, I get the following error message:

"Error during Transformation 'DirectCopyXform' for Row number 801.  Errors encountered so far in this task:  1. TransformCopy 'DirectCopyXform' conversion error:  Destination does not allow NULL on column pair1 (source: column 'my_col_name' (DBTYPE_R8), destination column 'my_dest_col' (DBTYPEI8))."

This is strange because my excel spreadsheet has only 800 rows, and none of them are null.  Is it possible that SQL Server is reading in my spreadsheet and is running right off the end of my data?  

In an attempt to understand what was going on, I created a test environment with an identical destination table that allowed nulls in my_dest_col.  With this, I was able to import successfully, but I got 2 null rows in my database for some (possibly all) tables.

One possible workaround is temporarily allowing nulls in the database in my production environment (while I import the data).  Then I could delete the erroneously imported null values and uncheck the box to allow nulls in enterprise manager.  Is it possible that this solution would cause damage to my database?  It's not under constant pounding, but a few people might fill out submission forms in that interval.

Comments by mid-morning 10/24 EST would be greatly appreciated since I'll probably try the import in production at that time.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anthony PerkinsCommented:
>>Is it possible that SQL Server is reading in my spreadsheet and is running right off the end of my data? <<
Correct.  Delete the "blank" rows at the end and your problem will go away.

>>One possible workaround is temporarily allowing nulls in the database in my production environment (while I import the data). <<
You should never import directly into a table (let alone in Production), but rather you should import into a temporary table first and then select the appropriate rows into the final table.  This way you can verify what is actually going in (remember the old adage: "garbage in, garbage out").

IgiwwaAuthor Commented:
I already tried to delete these "blank" rows and it didn't seem to make any difference.  I guess that's because Excel always gives you infinite empty rows and columns.  Is there any way I can make the spreadsheet just end after row 800?  Maybe I can use MS Access (*shudder*) as an intermediary.

Thanks for the tip about the temporary table, I will definitely use that regardless of the outcome of this problem.
Anthony PerkinsCommented:
>>I already tried to delete these "blank" rows and it didn't seem to make any difference. <<
I suspect it depends how you are deleting them.

In any case, when you import it in, use a query instead of a straight copy, as in:

Select *
From [Sheet1$]
Where Not [Column1] Is Null


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

I have not had any issues DTS from Excel to MS SQL Server. But I often use a funcky way to import data from excel to MS SQL Server.

For Example, say I have data listed below in a spreadsheet
Col1  Col2   Col2       Col4
1       A       XXXX    
2       B       YYYY

For Col4, I use excel function CANCATENATE to come up with a sql statement concatenating values in the other columns

=CONCATENATE( " INSERT INTO MYTBALE (COL1, COL2, COl3) VALUES (", A1, ",'", B1, "','", C1,"')" )

Then copy the column 4 data to Query explorer and execute it. The data is imported.

You may want to use this method if nothing helps.

If Excel is too dumb to work out where the data stops, you can select all the data and make it a named range (type a name into the cell drop down in the bottom left of the toolbar)

Then I think it is possible to tell DTS to only import the named range.

It's a bit impractical for a automted system though.
IgiwwaAuthor Commented:
I like acperkins suggestion:

Select *
From [Sheet1$]
Where Not [Column1] Is Null

It seems to work well in a test environment.  I was going to try it for real later today, but other stuff has come up so it may have to wait until next week, but it looks quite promising.

I agree with acperkins suggestion in every way.  Not only can you use the query to extract only the records you need, but you REALLY SHOULD use the temp table--makes it easier to "clean" any data ahead of time, and also makes it easier to back out data if you have a problem.....

IgiwwaAuthor Commented:
Ok.  I did the import and everything worked well.  There is just one small problem.  I have a unique id for each record.  Before the import I was in the mid 5000s.  To be able to easily identify the newly imported records, I started them at 10,000.  Now the auto numbering of sql is starting new records in the 10,000 block.  Is there any way I can make it start giving out ids in the 5000s again?
Anthony PerkinsCommented:
You cannot reassign the IDENTITY column to a lower number than already exists.  If this is not the case checkout the command:

From BOL:
Checks the current identity value for the specified table and, if needed, corrects the identity value.

    ( 'table_name'
        [ , { NORESEED
                | { RESEED [ , new_reseed_value ] }


IgiwwaAuthor Commented:
Thanks a lot everyone!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.