Wednesday, March 7, 2012

BULK Insert big Problem!

Hi!

Ive a little problem. I want to load my test.csv - file into a MS-SQL DB named EGN. Well, everythings well with this query:

sql = "BULK INSERT EGN FROM 'C:\inetpub\wwwroot\handy\crm\datenaufbereitung\te st.csv' With (KEEPIDENTITY,KEEPNULLS,MAXERRORS=0,FIELDTERMINATO R = ';',ROWTERMINATOR="&"'"&vbLf&"'"&") "

My only problem is, that i need the recordsets to be sorted. means: i need it in the same order as in the csv.-file.

my fields named:
Date, Minuten, Art, Daten, Destination, Nummer, Rufnummer, Gebuehr

all of them are varchar-fields...

hmmm..any idea?!?!

Thanks so much!

-arion--BULK INSERT ...
Add option ROWS_PER_BATCH=1
or if you can sort by columns in file
with option ORDER ( { column [ ASC | DESC ] } [ ,...n ] )
for more see BOL

Why do you need it?
If you SELECT from table, output seems to be sorted
by clustered index or insertion order, but you can
not be sure of this in MSSQLSERVER2K.
You must specify ORDER BY.

No comments:

Post a Comment