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.
| Author |
Topic |
|
sharcfinz
Starting Member
4 Posts |
Posted - 2010-08-27 : 18:35:48
|
| One of our tables got corrupted, and we ended up pasting data back into the newly created one from an excel spread sheet. One problem though. . . our table was originally sorted in numerical order by a column we called "fID". But when we copied the data into the table, it's no longer sorted by that when we open it to view in sql management studio. How do we get it back to sort by that column, so that it looks like our original table?? |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-08-27 : 18:39:25
|
select ... from ... ORDER by fID No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-08-28 : 00:45:26
|
| actually you dont need to worry about order in which you see records when you open it in SSMS. You can always retrieve in order you want using ORDER BY as webfred showed you------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
sharcfinz
Starting Member
4 Posts |
Posted - 2010-08-29 : 11:06:47
|
| visakh16, agreed, but the developer that I'm working with prefers to see this in that order, so we were trying to figure out a way for this to be done if possible. .. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-08-29 : 13:18:39
|
| you cant guarantee order of retrieval of records unless you use an order by in select.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-08-29 : 14:39:44
|
And to emphasize what the other are saying; you cant guarantee order of retrieval of records unless you use an order by in select. N 56°04'39.26"E 12°55'05.63" |
 |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2010-08-30 : 03:02:13
|
| I totally agree with what visakh and peso are saying but the fact that they're not showing up in the correct order might indicate a missing primary key / clustered index. I assume that when you're saying "showing up" you means that you click "show first 1000 rows" or something in management studio right? In that case the data usually is displayed in the order of the clustered index (I've never actually seen the clustered index showing up in the wrong order) and if it doesn't a very likely case is a missing index...- LumbagoMy blog (yes, I have a blog now! just not that much content yet) -> www.thefirstsql.com |
 |
|
|
|
|
|