I need to sort my SQL stored procedure recordset (shown below) alphabetically (by CustomerName), but also maintaining the sequential order of RecordID (meaning RecordID 2 is above RecordID 3, in relation to ParentID & ID fields). Any suggestions?
ID ParentID RecordID CustomerName
53445347 5344 2 Witt - 47
534453475345 53445347 3 Witt - 45
534453475346 53445347 3 Witt - 46
53445351 5344 2 Sjob - 51
534453515348 53445351 3 Sjob - 48
534453515349 53445351 3 Sjob - 49
534453515350 53445351 3 Sjob - 50
53445357 5344 2 Hal - 57
534453575355 53445357 3 Hal - 55
534453575356 53445357 3 Hal - 56
534453577252 53445357 3 Hal - 52
53446852 5344 2 Boston, - 52
534468526850 53446852 3 Boston, - 50
534468526851 53446852 3 Boston, - 51
534468527205 53446852 3 Boston, - 05
53447884 5344 2 Agri - 84
534478847883 53447884 3 Agri - 83
534478847957 53447884 3 Agri - 57
The intended output would be like:
53447884 5344 2 Agri - 84
534478847883 53447884 3 Agri - 83
534478847957 53447884 3 Agri - 57
53446852 5344 2 Boston, - 52
534468526850 53446852 3 Boston, - 50
534468526851 53446852 3 Boston, - 51
534468527205 53446852 3 Boston, - 05
53445357 5344 2 Hal - 57
534453575355 53445357 3 Hal - 55
534453575356 53445357 3 Hal - 56
534453577252 53445357 3 Hal - 52
53445351 5344 2 Sjob - 51
534453515348 53445351 3 Sjob - 48
534453515349 53445351 3 Sjob - 49
534453515350 53445351 3 Sjob - 50
53445347 5344 2 Witt - 47
534453475345 53445347 3 Witt - 45
534453475346 53445347 3 Witt - 46
if all your Customer names are formed as in your sample :
By the way, if you have any chance to change your model, split the alpha and the numeric part of CustomerName in two fields, and your life will be better, and the world will be as one.
If you can have customer names without the
-Rather try