I want to avoid a cursor for this one

  • Hi,

    OK, 2 tables, Job Cost joins to table ExpenseEntry a 1 to Many relationship

     

    I need to add a new column to the JobCost Table. In this column will be all the ExpenseEntries for that JobCost, with the values comma separated:

    JobCost table:

    JobCostUniqueID , NewColumn (ExpenseEntries)

    ----------------   --------------

    JC1                     E1,E2,E3

    JC2                     E1,E2

    JC3                    

    JC4                     E1, E2, E3,E4

    I could create a temp table populate it with the JobCostUniqueIDs then cursor through it. On each iteration, I would find the ExpenseEntries and append them to a vraiable, then just update the temp table with these values  - too many records, any idea how I can do this

     

    Many thanks

     

  • See, if this helps:

    http://sqljunkies.com/WebLog/amachanic/archive/2004/11/10/5065.aspx

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • No, you do not want to destroy First Normal Form.   Read **ANY** book on RDBMS basics for a description of normal forms.  Read **ANY** book on tiered architectures, which will tell you that dispaly is done in the front end, not the database.  This is vital, as well as fundamental. 

    Actually I also do hope, that it is a confusion of database and presentational layer. However, doesn't even MS do it?

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

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

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