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 |
Pete_N
Posting Yak Master
181 Posts |
Posted - 2012-01-09 : 07:30:09
|
The data is dunped into a table from a different system, read from a text file. I have no control over this. QuerySELECT LedgerKey, TransactionIMPID, IMPSequence, ClientLedger, CreatedDate, CreatedUserID, DestSortCode, DestAccountNumber, DestAccountName, DestBankRef, TransValue, TransCode, TransTypeFROM tbBOSS_TransactionIMPhow can I add a row number without changing the order of the data |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-01-09 : 07:33:15
|
In SQL, by the very definition, data in a table have no order. So if the data is already in the table, the order of the data is lost.If you are importing the data from somewhere that does have an order, for example from a csv file or excel file, you can include another column as you are importing it and have this new column hold a row number. |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-01-09 : 07:35:27
|
first define your order as per sunita explanation and then you can generate the rownumber using window function ROW_NUMBER()------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
Pete_N
Posting Yak Master
181 Posts |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|
|