What is the best way to sort records on Guid. Below never gives right results.
With UIDs As (--
Select ID = 1, UID = NEWID()
Union Select ID = 2, UID = NEWID()
Union Select ID = 3, UID = NEWID()
Union Select ID = 4, UID = NEWID()
Union Select ID = 5, UID = NEWID()
Union Select ID = 6, UID = NEWID()
Union Select ID = 7, UID = NEWID()
Union Select ID = 8, UID = NEWID()
Union Select ID = 9, UID = NEWID()
Union Select ID = 10, UID = NEWID()
Union Select ID = 11, UID = NEWID()
Union Select ID = 12, UID = NEWID()
Union Select ID = 13, UID = NEWID()
Union Select ID = 14, UID = NEWID()
Union Select ID = 15, UID = NEWID()
Union Select ID = 16, UID = NEWID()
)
Select * From UIDs Order BY UID, ID
Instead using Guid, how can i generate Sequential Integers in my select.
Thanks
SELECT *
FROM myTable
ORDER BY CAST(myGuid AS VARCHAR(36))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With