Results 1 to 3 of 3

Thread: [RESOLVED] [SQL2005] Sorting in a view?

  1. #1

    Thread Starter
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092

    Resolved [RESOLVED] [SQL2005] Sorting in a view?

    I have a Stored Procedure that selects data from a view as such
    Code:
    ALTER proc [dbo].[procMeetingSummary](
    @top int) as
    
    select top (@top) * from dbo.vwMeetingSummary
    In the view the data is sorted by a date field however when calling this stored procedure the results are un-sorted and I have to actually add an order by to the stored procedure.

    Is this a bug?

  2. #2
    Addicted Member
    Join Date
    Jan 2008
    Location
    Pittsburgh
    Posts
    169

    Re: [SQL2005] Sorting in a view?

    A view does not sort data. You have to do the sort in the SQL statement that references the view. The order by clause will just be ignored by a view so no this is not a bug.
    If you're going to be crazy, you have to get paid for it or else you're going to be locked up. -- Hunter Thompson

  3. #3

    Thread Starter
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092

    Re: [SQL2005] Sorting in a view?

    Thanks for clarifying schaefer.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width