Fetch last row in table with no unique identifier and without using ORDER BY
Without any sorting criteria there's NO WAY to achieve this. There's no guarantee for any order if you do a simple
SELECT * FROM xy
.
You could get your result in any sort order. Very dangerous: With small sets this might work accidentally in development and pass all your tests but breaks in production.
If you want to get the rows in the order of their insert you should add an IDENTITY
column.
If you want to enforce a pseudo-order you could try with ROW_NUMBER OVER(ORDER BY somecolumn)
AS PseudoInx
.