夏雷

积极人生,努力加油!
为什么会超时

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;

        }

 

这是简单的执行语句

posted on 2009-03-26 10:12  夏雷  阅读(238)  评论(0编辑  收藏  举报