In SQL Server, when you use the ORDER BY clause in a view, you gotta also use the TOP clause. That's because SQL Server needs a way to keep track of which rows go where when it shows you the results.
Now, there's a trick you can use with something called a Common Table Expression (CTE).
In our case, we make a CTE that gives each row a number based on the order we want (in this case, the "Typ" field). Then, we tell the main part of our SQL code to look at that CTE, but only choose the rows where the number isn't null.
This lets us sort our rows in the view without using the ORDER BY clause directly.
Instead, we're using the ROW_NUMBER() function in the CTE to get the sorting done
CREATE VIEW Vw_YourView
AS
WITH CTE AS (
SELECT guid,
Typ,
ROW_NUMBER() OVER (ORDER BY Typ) AS RowNum
FROM tbL_YourTable)
SELECT guid,
Typ
FROM
CTE
WHERE
RowNum IS NOT NULL;