sqlwrite does not preserve row order

7 Ansichten (letzte 30 Tage)
Kathryn
Kathryn am 9 Mär. 2023
Beantwortet: the cyclist am 9 Mär. 2023
I am writing a script to manipulate a .mat file containing a structure into a table and then write to a Microsoft SQL Server database. When I use the sqlwrite command, it does not seem to preserve the row order of the original table. The columns are all there and rows are written correctly, but the starting point is different every time I delete and rewrite the table. This is annoying as the data should be ordered by increasing time. Is there a way to preserve order when writing?
Thanks in advance for any help!

Akzeptierte Antwort

the cyclist
the cyclist am 9 Mär. 2023
Even if you store the data in a particular order (which you should not try to do), there is no guarantee that any given SELECT statement will retrieve the data in that order. I know for a fact that this is true in PostgreSQL, and I am confident that this is true in the major databases systems.
Users who need records in a particular order must use the ORDER BY clause (or equivalent).

Weitere Antworten (0)

Produkte


Version

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by