为什么会超时
select [PR].[RegionID] AS ID,count(*) as cnt from dbo.PositionRecruiting [pr] where IsPublic = 'Y' AND [regionID] = @regionID group by [PR].[RegionID] UNION select [PR].[RegionID],count(*) as cnt from dbo.PositionRecruiting [PR] INNER JOIN [region] ON region.RegionID = [PR].regionID where IsPublic = 'Y' AND [region].ParentID = @regionID group by [PR].[RegionID] ORDER BY cnt DESC
select [PR].[RegionID] AS ID,count(*) as cnt from dbo.PositionRecruiting [pr] where IsPublic = 'Y' AND [regionID] = @regionID group by [PR].[RegionID] union select [PR].[RegionID],count(*) as cnt from dbo.PositionRecruiting [PR] INNER JOIN [region] ON region.RegionID = [PR].regionID where IsPublic = 'Y' AND [region].ParentID = @regionID group by [PR].[RegionID] ORDER BY cnt DESC
2个语句 UNION 的大小写不同。 执行起来 大写会超时 小写正常 为什么呢?
/// <summary>
/// 一般SQl查询
/// </summary>
public static DataTable ExecuteDataTable(string cmdText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand();
SqlConnection conn = new SqlConnection(ConnString);
DataTable dt = new DataTable();
PrepareCommand(cmd, conn, null, CommandType.Text, cmdText, commandParameters);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
adp.Fill(dt);
cmd.Parameters.Clear();
if (conn.State != ConnectionState.Closed)
conn.Close();
return dt;
}
这是简单的执行语句