"order by" in a stored procedure

Results 1 to 3 of 3

Thread: "order by" in a stored procedure

  1. #1
    Peppe Bergqvist Guest

    Default "order by" in a stored procedure

    Uses the code below in a sp, but when I try to add som order by or sort by, it fails. Anyone with at bit of code that works?<BR><BR>Peppe<BR><BR><BR>CREATE PROCEDURE [sp_tempsites_read] <BR><BR>@session numeric(9)<BR><BR>As<BR>(Select tb_tempsites.id, tb_tempsites.site, sites.url, sites.name From tb_tempsites, sites<BR>where tb_tempsites.session = @session and tb_tempsites.site = sites.id)<BR><BR>GO

  2. #2
    Join Date
    Dec 1969
    Los Angeles, CA

    Default Would you like fries with that ORDER

    create proc sp_tempsites_read<BR>(<BR>@session numeric(9)<BR>)<BR>As<BR>Select tb_tempsites.id<BR> , tb_tempsites.site<BR> , sites.url<BR> , sites.name <BR>From tb_tempsites<BR> , sites<BR>where tb_tempsites.session = @session <BR>and tb_tempsites.site = sites.id <BR>order by tb_tempsites.id<BR><BR><BR>this looks good enough to work unless i missed something. What error were you getting when you tried it

  3. #3
    Peppe Bergqvist Guest

    Default RE: Would you like fries with that ORDER

    discovered that I&#039ve tried to put the "order by" inside (), now I putted it outside of it and now it works fine!<BR><BR>Thanks!<BR>Peppe

Posting Permissions

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