my stored procedeur like this:
alter PROCEDURE [dbo].[ParkingDeatailsReportnewstack]
@startdate NVARCHAR(100),
@enddate NVARCHAR(100)AS
BEGIN
DE
Try migrating your order by
clause into the outermost select statement — the only place where order by
makes any sense.
Something like
select LocName ,
...
from ...
order by LocName
Or, even simpler, wrap the original, complex select
in an outer select whose sole purpose is ordering, along these lines:
select *
from ( select
...
) t
order by t.x, t.y , ...
We can fix the problem very easily by adding a TOP 100 PERCENT clause into the view definition. Try using this way - http://www.sqlpassion.at/archive/2015/05/25/the-ambiguity-of-the-order-by-in-sql-server/