November 4, 2004 at 12:46 pm
Hi,
I want to retrieve rows from a database table in the order in which they were inserted into the database. By default, BCP is sorting in alphabetical order. Any ideas on how I can do this without SQL voodoo or identify fields?
November 5, 2004 at 2:18 pm
Not sure if I understand correct, but why don't you use a query with an ORDER BY according to your columns?
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
November 5, 2004 at 5:34 pm
It's like this. When you open up SQL Server and view all rows, it returns the results in what looks like the order in which they hit the database, by default. I was told that unlike Oracle, SQL Server doesn't keep any hidden identifiers. I was just curious about how SQL Server does its default sorting, really. =)
November 6, 2004 at 1:48 pm
When the table is a heap, I think the order is quite random. When the table has a clustered index, I believe this to be in order of the clustered index. Anyway, you shouldn't rely only on this. That's why I meant, use an ORDER BY, as this is the only reliable way to get the sorted result you expect.
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy