Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Express Edition and Compact Edition (2005)
 Different Order of the Records

Author  Topic 

sky1224
Starting Member

12 Posts

Posted - 2009-12-16 : 21:22:10
Good morning.
I'm upsizing the old MS Access (mdb) file to the SQL Server...

But in some tables, the order of the records are different between two DB Engines. In mdb, the records are ordered by the first field, but in SQL Server the records aren't ordered...

So the results of the queries are also different!

What can I do???
Help me, please... Thank you...

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-16 : 21:23:22
Add an ORDER BY to your queries to guarantee the order as SQL Server does not order it for you.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

sky1224
Starting Member

12 Posts

Posted - 2009-12-16 : 21:36:39
Thank you for your help, but anything is still wrong...

I'm using the Microsoft SQL Server Management Studio. As you say, I repaired my SQL statement and executed with ORDER BY in <New Query> window.

Then the results was corretly orderd.(Thank you.)

But the sql statements of View doesn't run correctly...(I made the View SQL select orderby query and the right click it and <Open View>. Then the results wasnot correct..)

Once again, please help me. Thank you.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-16 : 22:05:34
You need to add the order by when you query the view:

SELECT *
FROM ViewName
ORDER BY SomeColumn

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

sky1224
Starting Member

12 Posts

Posted - 2009-12-16 : 22:59:39
Thank you very much!
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-16 : 23:18:52
You're welcome, glad to help.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-12-17 : 02:23:04
<<
I made the View SQL select orderby query and the right click it and <Open View>. Then the results wasnot correct..
>>

It is not possible to create a view with Order by clause without using a TOP operator
Also,it is not gauranteed that the result is sorted even if the view has Order by clause

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

sky1224
Starting Member

12 Posts

Posted - 2009-12-17 : 03:31:31
You're right, Mr. madhivanan!

In mdb, records was not ordered! I made a mistake...
Thank you for your advice.

And Thank you for everybody!!! :-)
Go to Top of Page
   

- Advertisement -