mjburgard
asked on
Import from excel question
I am using an excel spreadsheet to import some data into a table in our sql database. The issue is that the table contains a field that is a unique number that is generated for each contact address. It is not used anywhere else in the database, but it is not nullable.
I am using the import wizard to import this data - Is there a command I can add to the query it generates that will increment this number for every new entry the SQL import tries to insert?
I am using the import wizard to import this data - Is there a command I can add to the query it generates that will increment this number for every new entry the SQL import tries to insert?
ASKER
I will try the work around -
It is a number, however it is not a key, but it does appear in the Indexes folder of the table.
It is a number, however it is not a key, but it does appear in the Indexes folder of the table.
ASKER
Yes -
it is an identity column
it is an identity column
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This was what I needed to get the job finished. There was a bit more that I needed to do, but this solved the issue I was having.
Is this number in the spreadsheet?
Is this number an identity column in SQL?
As a work around, import the spreadsheet into another table, and then copy the contents from this work table to the main one.
ie
insert dbo.MainTable( col2, col3, col4 )
select w.col2, w.col3, w.col4
from dbo.WorkTable w
left outer join dbo.MainTable m
on m.SomeKeyCol = w.SomeKeyCol
where
m.SomeKeyCol is null
;
HTH
David