I have following view
CREATE VIEW ...
AS SELECT TOP (100) PERCENT ...
FROM ...
INNER JOIN ...
ON ...
WHERE ...
ORDER BY datetime2 DESC
I also have a stored procedure with a
SELECT TOP(1) ... FROM ... WHERE ...
without an 'ORDER BY' declaration. (i am also fixing it). The programm, which is executing this usp, also writes a lot of informations in the dependent table. So the request can be executed, while the view got new informations.
First of, we executed some 'SELECT ... WHERE...' statements on the view, which ended unsorted. Why is it unsorted, the view should sort it by the datetime2-Column.
I am expecting mixed results by the 'SELECT TOP(1)' statement without the 'ORDER BY' append. But actually there are less wrong results as expected and they are on a specific period. 2 Days in April, 2 Days in November. The datas in the view are also mixed, there shouldn't be a statistical reason, why the result gives me some datas more often than other one.
I couldn't find any connection between the datas, also not in the environment. Is it just an unlucky situation? A 'trap' that lets me think, there is a connection?
Is there a way to reproduce the 'failure'. (actually it's a correct behaviour from the system)?
I hope you got enough information to help me out! If there are some questions, of course I'll answer them.
EDIT same day - 09:32 UTC: the important part of the usp is, that it insert into a table the result of the `SELECT TOP(1) ... FROM ... WHERE ... '. There are no conditions around.