Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Random Insert in Table

Status
Not open for further replies.

gust1480

Programmer
Mar 19, 2002
148
PH
How can I make an insert do the insert on the last row? Because I notice on my table that when I do an insert it insert the data randomly. Do i need to change some properties on the SQL?
 
No.

What you need to understand (and get comfortable with) is the fact that the physical ordering of the rows is NOT important and should not be important.

Whenever you display the data to the user in a grid type of format, you should ALWAYS include an order by (so that the rows appear in the order that makes sense for the display).

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Thanks george! So there is really no way to do it huh!?!

 
There may be ways to accomplish what you want, but it's easier just to an an order by on the select query that returns the data.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
There is no order only Zule! :)

Relational tables and views are unordered sets by definition. Yes, you can put a clustered index on your table and the data will be physically ordered. But, that still does not mean that the data is guaranteed to be returned in that order. There are a number of reasons including cache hits, parallelism and such, but that is beyond the scope right now. As mentioned by gmmastros, the only way to guarantee the order of a select is to order by what ever column(s) you want.

Hopefully, that helps

-Ryan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top