Rows Are Automatically Moved Here And There In A Random Fashion In SQL

Hello Experts,

In the starting I thought there is some problme in my VB Coding, I debugged it a lot but to no results.

Suddenly I thought let me try entering Rows from MS-SQL Enterprise Manager only before looking into the VB Module Code.

In my Database Table, there is no primary field, all fields Allow Nulls is checked. Table consists of 18 fields of char,varchar, date etc.

After Moving to the last row, When I enter Records say 3 at a go and then closes the table and again open it I found that that out of three, 2 are placed in between and 1 in the last.
It is happening everytime and whatever I enter, sometimes 1 is placed in the last, 1 is placed somewhere and another 3rd somewhere else.

I have nothing as such defined on the table. According to me it should be like the records should come the way I am entering, the order should be like this only.

Why this is happening, please tell, if you have any ideas.

Best Regards

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
The order in which the rows are stored is not garantueed, unless you have a clustered index. And even in that case, the physical representation is not a simple list, but an ordered and balanced tree... For tables with clustered keys, the normal sequence will be the one of the index, but even that is not guaranteed.
If you want to get your rows ordered (in the application), then you need to supply an ORDER BY clause when querying for the data. In the EM, you can use the GRID PANE, choose the colum you want to sort by (below the default *), set the "sort type", and eventually uncheck the "output" flag. You should play around with this to see what the result gives after you change these settings and click on the execute button (!). You can also display the SQL by activating the SQL VIEW pane.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.