Help with nested procedure

  • Hi Gang,

    I'm trying to solve a nesting problem. I'm sure this is simple, but I'm learning SQL as I go. Here's the situation:

    1) I have a procedure (we'll call it DumpData). Dump data takes data from several tables and provides it for processing to an non-SQL (ASP Page) process. Dump Data returns Product_Number as part of it's output.

    2) I need to add the colors that each product comes in to the output of the procedure.

    3) I have built another stored procedure with some trinkets I found on this site that returns the list of colors as a concatenated object. (basically a single Cell or data item).

    What I can't figure out how to do is combine the pieces.

    I want to call DataDump and have it build a result set that consists of information in the tables (Product_Number, Description, Price, etc) and also contains the results of Findcolors .

    Essentially the execution concept would be that it would call findcolors for each row in the resultset. The data from findcolors (essentially a concatenated column) would be output as a field in dumpdata.

    So my question is:

    1) Is this doable?

    2) Aside from efficiency (which we don't care about right now) what's the simplest way to implement this? (the reason we don't care about efficiency is that we are working with 160 products that range from 1 to 35 colors. We only call this once or twice a week to build a CSV file)

    Thanks,

    I can post code if someone is interested, but the post above contains sufficient information I think. I'm interested as much in learning how and why as in learning what to type.

    Thanks,

  • Are these two seperate tables?

    If so, I presume in the Colours table you have a foreign key that you could join into the primary table?

    Maybe posting (brief) designs of your tables would help...as well as some code!

    Cheers,

    Clive Strong

    sqlsrvr_dba@hotmail.com

  • IF you have a complex process to Findcolors, make a Function, you can call it in a select statment.

  • Actually, The function is exactly what I ended up doing. It made the query run alot longer, but it's no big deal. I figured out how to get it to work at 1:30AM last nite... 🙂

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply