lists in stored procedure

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

  1. #1

    Default lists in stored procedure

    Hi,
    I am trying to write a stored procedure that would do something like this
    create proc test
    @category int,
    @itemList varchar(100)
    as
    begin
    set @itemList='select itemID from table.items where category=@category'
    EXEC sp_executesql @itemlist

    select * from table.itemdesc
    where itemId in (@itemlist)
    end
    go

    so the idea, is to get all the rows in the table that meet a certain
    constraint, pass the id's of those rows to another query that would get the
    info for the specific item.

    I also need to find out how to make the query loop over a list of inputs and
    return the relevant data,
    thanks

    Msabry Guest

  2. Similar Questions and Discussions

    1. Stored Procedure
      EXEC master..xp_cmdshell 'cscript c:\path\file.vbs' EXEC master..xp_cmdshell 'c:\path\file.exe' "Kannan" <gk_i@yahoo.com> wrote in message...
    2. SQL Stored Procedures and Lists of Strings
      Hey all. I've been pulling my hair out all day today trying to get this to work. I can do what i want to do in a straight <cfquery>, but i'm...
    3. stored procedure help
      Hi all! I am in need of writing a few stored procedures. The first one is to create a stored procedure to recover a database from backup and the...
    4. stored procedure value
      How can I bind a stored procedure value to a page? I've executed a stored procedure and there should be two column values created...i.e. col1 and...
    5. Stored procedure?
      Stored procedure ?? -- Message posted via http://www.dotnetmonster.com
  3. #2

    Default Re: lists in stored procedure

    why bother w/a list & all that:

    SELECT *
    FROM table.itemdesc
    WHERE itemId IN
    (
    SELECT itemID
    FROM someTable.items
    WHERE category=@category
    )


    or do a JOIN or use EXISTS
    PaulH *ACE* 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