• Why looping? SQL doesn't need any form of looping to get master-detail information. You'd write a single query with a join across the two tables. Something like this:

    SELECT Master.Col1, Master.Col2, Detail.Col1, Detail.Col2, /*more columns*/ FROM Master INNER JOIN Detail on Master.PrimaryKeyColumn = Detail.MasterPrimaryKey

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass