简体   繁体   中英

SQL Server 2008 R2, Query exiting after 65536 rows

As the title says, I am facing a peculiar problem with SQL Server 2008 R2. I am currently working with huge dataset in Analytics project, almost 1 million rows in each table. Now the problem is, if I run a query with normal select statement like Select * from Table... Gives me the whole table results, even a where condition gives the perfect results.

But as soon as I use any aggregate function in a query, then I am getting only 65536 rows , after which the query is exiting. Now I am cent percent sure that the result set is much huge than the one returned. Steps I tried before raising the question. 1) Tried increasing the result to grid size in SQL Server Management Studio, Options.It is maxed out at 65536 2) Exporting to CSV using the query. The total no of rows is 65536 3) Exporting to Excel.. Same problem.

Kindly guide me as to what am I doing wrong.

For reference, I am posting the SQL Query for which I am getting this problem.

select a.Store,a.Seq_Item, MIN(a.Date) StartDate,MAX(a.Date) EndDate,SUM(a.Transaction_Items)tot_sales, COUNT(a.Transaction_Items)tot_sales_day,(DATEDIFF(DAY, MIN(a.Date), MAX(a.Date))+1)actual_days, ROUND(SUM(a.Transaction_Items)/CAST(COUNT(a.Transaction_Items) as float),2)avg_sales_per_sales_day, ROUND(SUM(a.Transaction_Items)/CAST((DATEDIFF(DAY, MIN(a.Date), MAX(a.Date))+1)as float),2)avg_sales_per_actual_day, round((ROUND(SUM(a.Transaction_Items)/CAST(COUNT(a.Transaction_Items) as float),2)/ ROUND(SUM(a.Transaction_Items)/CAST((DATEDIFF(DAY, MIN(a.Date), MAX(a.Date))+1)as float),2)),2)sales_day_velocity, ROUND(round((ROUND(SUM(a.Transaction_Items)/CAST(COUNT(a.Transaction_Items) as float),2)/ ROUND(SUM(a.Transaction_Items)/CAST((DATEDIFF(DAY, MIN(a.Date), MAX(a.Date))+1)as float),2)),2),0) category from Store129 a group by a.Seq_Item,a.Store order by a.Seq_Item

Now, I am working in Amazon Server hosting environment, and have the option of Upgrading my SQL server version to Standard Edition. Currently it is Express edition. Now, if I upgrade, would that solve my issue.

Regards, Arindom Ray Chaudhuri

http://msdn.microsoft.com/en-us/library/ms143432.aspx

That's a batch size so maybe try loading the results into a temporary table and then query from it. Might not be the perfect solution.

Pardon me for the 'answer' i cant comment due to the lack of points.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM