1 votes

Most Recent Records View

When you want to make a view that shows me the most recent records, I get this error, what could it be? also it automatically inserts the top 100 when I did not write that

 SELECT        TOP (100) PERCENT sales_order, customer, total_qty, total_por_ticket_qty, model, CONVERT(varchar, date_received, 6) AS Date_Received, CONVERT(varchar, due_date, 6) AS Due_Date, priority, categoria, 
                     CAST(Pz_por_hora AS decimal(11, 2)) AS Pz_por_Hora, CONVERT(varchar, cut, 6) AS Cut, CONVERT(varchar, sw630a830, 6) AS Sw630a830, CONVERT(varchar, sw830a1030, 6) AS Sw830a1030, CONVERT(varchar, sw1030a1230, 
                     6) AS Sw1030a1230, CONVERT(varchar, sw1230a230, 6) AS Sw1230a230, CONVERT(varchar, sw230a430, 6) AS Sw230a430, CONVERT(varchar, sw430a630, 6) AS Sw430a630, CONVERT(varchar, sewing_groupB, 6) 
                     AS Sewing_GroupB, CONVERT(varchar, inspection, 6) AS Inspection, CONVERT(varchar, ready_to_ship, 6) AS Ready_to_ship, shipped_date, shipping_containers, comments, CAST(points_unitarians AS decimal(11, 2)) 
                     AS Points_Unitarians, CAST(total_points AS decimal(11, 2)) AS Total_Points FROM dbo.tbl_Daily ORDER BY id_Daily DESC

enter the description of the image here

1voto

Patricio Moracho Points 24098

It is not a mistake, it is a warning. Basically what it is telling you is that in a View the clause ORDER BY only used to determine which rows are going to be displayed, but it does not establish the order in which they are finally going to be sorted. In your example you are also doing a TOP 100 PERCENT, that is, you are going to show all the rows that the query returns, so you could directly ignore the ORDER BY clause.

HolaDevs.com

HolaDevs is an online community of programmers and software lovers.
You can check other people responses or create a new question if you don't find a solution

Powered by:

X