all groups > sql server programming > january 2006 >
You're in the

sql server programming

group:

bulk insert in the exact sequence as the text file


bulk insert in the exact sequence as the text file Mark
1/31/2006 10:09:22 PM
sql server programming:
I'm having an issue when doing a bulk insert on a SQL 2000 server. I
need
the table rows to load in the exact order that the rows in the text
file are
sequenced.

So far, the bulk insert appears to be loading the file in 2 different
orders. One of the orders is the same order as the text file. The
other
order is completely different and does not appear to have any reason to
be in
the different order.

I've tried setting the BATCHSIZE argument to 1 and that doesn't fix it.

Using the ORDER argument doesn't help either because the destination
table
doesn't have a primary key plus I don't want to change the order of the
text
file anyways.

Is there a way to ensure the BULK INSERT loads the file in the exact
order
that the text file is in?
Re: bulk insert in the exact sequence as the text file Damien
1/31/2006 11:45:40 PM
[quoted text, click to view]

Hi Mark,

Tables in SQL do not have an order, or at least, not one that you have
any control over. I'd suggest you search this newsgroup for previous
discussions of order within a table for the explanations.

Damien
Re: bulk insert in the exact sequence as the text file David Portas
2/1/2006 1:17:42 AM
[quoted text, click to view]

Tables don't have any inherent order. You need to add a key to your
target table and order on that when you query the data.

What order is your file data in? If that information isn't contained in
the file data itself then you may need to add it yourself or use a
different method of loading so that it can be added during the load.

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--
AddThis Social Bookmark Button