Thank you, Hardik, but I don't think this would work.
Actually, I created the View1 based on a couple of tables, the SQL scripts
are too long to publish, then I created the second view. Here are the
original scripts for View1:
SELECT TOP (100) PERCENT dbo.TMBR.MID, dbo.TSVCDEF.SNAME,
dbo.TPRSLSTDTL.PRS, dbo.TMCPLST.TREF,
dbo.TPRSLST.DV, dbo.TPRSLST.DIV, dbo.TMBRCAT.MTYPE
FROM dbo.TPRSLSTDTL INNER JOIN
dbo.TPRSLST ON dbo.TPRSLSTDTL.PRSNAME =
dbo.TPRSLST.PRSNAME INNER JOIN
dbo.TMBR INNER JOIN
dbo.TMBRCAT ON dbo.TMBR.MBRCAT = dbo.TMBRCAT.TYPEID
INNER JOIN
dbo.TMCPLST ON dbo.TMBRCAT.TYPEID = dbo.TMCPLST.MBRCAT
ON dbo.TPRSLST.PRSNAME = dbo.TMCPLST.PLSTREF INNER JOIN dbo.TSVCDEF ON
dbo.TPRSLSTDTL.SKU = dbo.TSVCDEF.SKU
ORDER BY MID, SNAME
in the last line, I explictly asked the view to sort the record by MID and
SNAME, but I will run into the same error as I stated before. When open it
directly, I mean I would not open it by clicking modify item, the result
would not be sorted as asked at all.
Jak
"Hardik Bati [MS]" <hardikb_removethis_@microsoft.com> wrote in message
news:%23X%23x3DXcHHA.5060@TK2MSFTNGP06.phx.gbl...
>
> This should work.
> use tempdb
> go
>
> create table T1(a int, b int, c int)
> go
>
> create view V1
> as select top(100) percent a, b,c from T1
> go
>
> select TOP(100) percent a, b
> From V1
> order by a
> go
>
> Here the output is sorted by a since its explictly asked.
>
> If you had defined the view as such where the order by is within the view
> then there is no assurance of the order comming from the view. Unless
> explicitly asked for.
>
> create view V2
> as select top(100) percent a, b,c from T1
> order by a
> go
>
> select * from V2
> go
>
> Hardik
>
> "Jak" <NO-spam_cnlohmann@yeah.net> wrote in message
> news:elcfIBUcHHA.4516@TK2MSFTNGP04.phx.gbl...
>> Hi, all,
>>
>> When I try to open the query in the new query page, the result returned
>> does not sort as expected, but if I modify and run it, the result would
>> be sorted. The SQL codes are as follows:
>>
>> SELECT TOP (100) PERCENT MID, SNAME, TREF, DTEFT
>> FROM dbo.View_1
>> ORDER BY MID
>>
>> the management tool is Microsoft SQL Server Management Studio Express
>> running under Windows XP x64 + SP2, the SQL Server Express has been
>> patched with SP2 already.
>>
>> Regards,
>>
>> Jak
>>
>
>