我通過CLR執行下面的代碼,是否有一個原因爲什麼郵件不打印到SQL Server,它是否需要等待,直到存儲過程返回所有行(那裏大約是7億行返回)SQLDatareader通過CLR不返回SQL消息正確的方式
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "spCommand_Select_Rows_For_Delete";
cmd.CommandTimeout = 41600;
SqlDataReader reader = cmd.ExecuteReader();
try
{
string strSQL = "";
SqlContext.Pipe.Send(DateTime.Now.ToString() + " - Started working with ProductTable");
while (reader.Read())
{
strSQL = "DELETE FROM ProductTable WHERE ProductId = " + reader["ProductId"].ToString();
SqlCommand cmdDelete = new SqlCommand(strSQL, conn);
cmdDelete.Connection = conn;
cmdDelete.CommandTimeout = 20800;
cmdDelete.ExecuteNonQuery();
}
SqlContext.Pipe.Send(DateTime.Now.ToString() + " - Completed working with ProductTable");
}
finally
{
// Always call Close when done reading.
reader.Close();
}
我的存儲過程:
SELECT ProductId FROM ProductTable
WHERE ProductInfoId IN
(
SELECT ProductInfoId from DeletedProducts
)
從存儲過程中有7億行?所以你從一個較大的行刪除了70億行***一個接一個***? – gbn 2010-07-28 19:40:11
哇,這就是爲什麼在RBAR中有一個A. – 2010-07-28 21:23:01