If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > MSSQL/Great Plains using DEX_ROW_ID to sort

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-20-09, 00:07
monicas monicas is offline
Registered User
 
Join Date: Apr 2009
Posts: 3
MSSQL/Great Plains using DEX_ROW_ID to sort

We are using MSSQL to manage different systems, we use the input from Great Plains and then we post some information to other systems.

I started having some problems and we post a big invoice, the order was not correct. If I print the invoice the order was the correct one but if I open the MSSQL table, the order was not correct. After several test I found that if I sort using DEX_ROW_ID, I'll get the order order. Is this correct?

What is the best way to sort the table in base of the time when the row was created?

Thanks,
Monica
Reply With Quote
  #2 (permalink)  
Old 04-20-09, 04:34
Wim Wim is offline
Registered User
 
Join Date: Nov 2004
Posts: 1,279
Quote:
After several test I found that if I sort using DEX_ROW_ID, I'll get the order order. Is this correct?
Probably, but hard to tell without any further information.
Quote:
What is the best way to sort the table in base of the time when the row was created?
ORDER BY CreationTimestampColumnName
__________________
With kind regards . . . . . SQL Server 2000/2005/2008/2008 R2 Earned beers: 16
Wim
Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald Knuth
Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages
Reply With Quote
  #3 (permalink)  
Old 04-20-09, 09:09
monicas monicas is offline
Registered User
 
Join Date: Apr 2009
Posts: 3
Well, I tried to use CreationTimeStamp but I get an error. My table does not have a timestamp column.

My table has a column called RecordedTime and I have the date and time when the row was created; the problem is that the time is the same for a lot of rows.

The DEX_ROW_ID is just a consecutive number. Do you see any problem if I use this field to order my query?

Thanks,
Monica
Reply With Quote
  #4 (permalink)  
Old 04-20-09, 10:08
Wim Wim is offline
Registered User
 
Join Date: Nov 2004
Posts: 1,279
If DEX_ROW_ID is an identity column, its values will be in the order of creation. In most cases it will be safe to use it in your ORDER BY clause.
Quote:
After several test I found that if I sort using DEX_ROW_ID, I'll get the order order.
As you already stated, in your case it will work.

A better design would keep an extra column like InvoiceLineNr (or some similar name), to store the sequence explicitly. Perhaps some column with that name is present?
__________________
With kind regards . . . . . SQL Server 2000/2005/2008/2008 R2 Earned beers: 16
Wim
Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald Knuth
Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages
Reply With Quote
  #5 (permalink)  
Old 04-20-09, 11:50
monicas monicas is offline
Registered User
 
Join Date: Apr 2009
Posts: 3
I don't have another identity column. I'm going to use DEX_ROW_ID and reply to the post if I find any problems.

Thank you very much.
Monica
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On