Updated table has changed the row order

G

Guest

Hi,

1/
I inserted new data to the database using SQLDataAdapter. All data are
inserted, but the order of rows in db table is not identical with the order
in DataTable used for the batch update.

No sorting is made.

This occures when I insert more then 800 or 1000 rows.

2/
I tried to use ExecuteNonQuery in a loop also, and the result was the same.
If I inserted more rows then approximatelly 800, the row order in target
table has been changed.

Is it caused by some kind of caching? How to avoid this?

Thanks,

Lubomir
 
P

Patrice

IMO rows are really inserted using the order you gave but generally speaking
when you query rows from a database wihtout specifying a particular order
they are returned as the DB wants (for example rows that are stored
physically on the same pages are likely kept together). If you want a
particular order, you have to specify the order in your data retrieval
operation (for example using the automatically incremented pk if you want
them by chronological order).
 
W

William \(Bill\) Vaughn

Ah, the order in which the rows are stored or returned is not guaranteed in
any (serious) relational engine. The ONLY way to ensure that the rows are
physically ordered is to create (in SQL Server) a clustered index. The best
way to ensure that rows are returned in a logical order is to use an ORDER
BY clause in the SQL query.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
 
G

Guest

Thank you for help.

Lubomir



William (Bill) Vaughn said:
Ah, the order in which the rows are stored or returned is not guaranteed in
any (serious) relational engine. The ONLY way to ensure that the rows are
physically ordered is to create (in SQL Server) a clustered index. The best
way to ensure that rows are returned in a logical order is to use an ORDER
BY clause in the SQL query.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top