SQL Server Performance

build temp array and return this to client

Discussion in 'SQL Server 2005 CLR' started by skeezwiz, Sep 12, 2006.

  1. skeezwiz New Member

    How can you loop over a data reader and save the current row to a temp array of some sort and return this array back to the caller?

    SqlDecimal total = 0;
    SqlConnection conn = new SqlConnection("Context Connection=true");
    SqlCommand cmd = new SqlCommand(@"SELECT column1, column2, column3
    FROM table ", conn);


    SqlDataReader rdr = cmd.ExecuteReader();

    while (rdr.Read())
    if (rdr.GetSqlString(1) == "01")
    // ADD the current record to a temp list
    total = total + rdr.GetSqlDecimal(2);



    // RETURN the temp list


Share This Page