Sproc Result as Comma Seperated List

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Sproc Result as Comma Seperated List

    Hey guys,

    I had built some photoblogging software in the past and am currently just
    revising it to bring it up to validated xhtml and running solely on stored
    procedures.

    At the beginning of the application, I initiliaze a session.list with ID's of
    the photo entries. This is to control the next / previous functionality. I'm
    doing this in cf right now, building a list with a loop of the result set. Is
    there a way in SQL to build this comma seperated list in a SPROC, and just
    bring that back to CF to manipulate.

    Here's my code, but it's giving me an error.

    DECLARE @EntryList varchar(255)
    SET @EntryList = (SELECT Entry_ID
    FROM V2_Entry
    WHERE Active = 1
    ORDER BY EntryDate ASC)

    Error = Server: Msg 1033, Level 15, State 1, Line 5
    The ORDER BY clause is invalid in views, inline functions, derived tables, and
    subqueries, unless TOP is also specified.

    dj shane Guest

  2. Similar Questions and Discussions

    1. Looping a list in SQL 2000 SPROC
      Hey guys, just trying to learn something new today and wanted to convert one of my cf pages to a sproc. This page just sets up security for the...
    2. Comma displays in List?
      Hi there, I've done a few searches and couldn't find this question posted yet, so please forgive me in advance if its a reapeat. I have an XML...
    3. comma delimited list problem
      I have a comma delimited list that is loaded into flash using loadvars. How can I convert it into an array? thanks in advance. Shaun
    4. Splitting Comma delimited list
      Hello everyone, I use the following to split a comma delimited list and get varying results and I don't understand why. my count of the...
    5. Reg. Perl script to read comma seperated file.
      Hi, I do know how to read the comma seperated file using the following script while ($lines = <INFH>){ if ($lines =~ /^\s*$/){ last; } @flds...
  3. #2

    Default Re: Sproc Result as Comma Seperated List

    dj shane wrote:
    > doing this in cf right now, building a list with a loop of the result set. Is
    > there a way in SQL to build this comma seperated list in a SPROC, and just
    > bring that back to CF to manipulate.
    probably but wouldn't it be simpler to use valueList() on the returned resultset?
    PaulH *TMM* Guest

  4. #3

    Default Re: Sproc Result as Comma Seperated List

    This is how you do this kind of thing in SQl Server
    --test in pubs to understand how it works

    DECLARE @EntryList varchar(255)
    SELECT @EntryList =''
    SELECT @EntryList = @EntryList + au_fname +','
    from authors where state ='UT' and state is not null
    order by au_fname

    select Left(@EntryList,len(@EntryList)-1)

    then your would be something like this

    DECLARE @EntryList varchar(255)
    SELECT @EntryList = @EntryList + Entry_ID +','
    FROM V2_Entry
    WHERE Active = 1
    ORDER BY EntryDate ASC

    select Left(@EntryList,len(@EntryList)-1)

    SQLMenace Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139