• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 44
  • Last Modified:

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
Austin

0
austin123
Asked:
austin123
1 Solution
 
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.

CHeers
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now