If I run a stored procedure in SSMS, it takes threee seconds. Calling the same procedure from C# takes minutes to return. I suspect that the longer execution times are the result of the number of rows returned. One parpameter case that does not return (in the time that I have been willing to wait) returns 38,000 rows.
How do I speed up queries that return a lot of rows?
Thanks.
Here is the C#:
DataSet ds = new DataSet();
DataTable dt = new DataTable();
SqlCommand cmd = new SqlCommand(query, conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandTimeout = 60000;
cmd.Parameters.Add("@Family_Code", SqlDbType.VarChar).Value = "SPCF";
SqlDataReader dr = cmd.ExecuteReader(); // takes 'forever'
dt.Load(dr);
ds.Tables.Add(dt);