Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 3rd, 2005, 04:25 AM
Authorized User
 
Join Date: Sep 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL vs CR summing

Could anybody tell me or what is the preferred method when passing data to a Crystal Report 9 from a stored proc within SQL Server 2K.

Method 1: Summing data in SQL Server and passing the summed data to CR (no summing done in CR)

Method 2: Passing the resultset to CR and letting CR do the summing on the client PC

I am currently using method 2 though I am beginning to think that letting SQL do all the summing first may be quicker.

Any views appreciated

Regards
D

 
Old October 3rd, 2005, 06:56 AM
Authorized User
 
Join Date: Sep 2005
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I would go for option 2 this way your DB doesn't slow down if 50 people suddenly request a report


http://sqlservercode.blogspot.com/
 
Old October 3rd, 2005, 07:05 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

On the other hand, sending back a bunch of data to the client for the sole purpose of having the client aggregate it slows the whole network down with unnecessary traffic.

It's a tradeoff.

I generally prefer to have the server do the grouping and aggregation. It's better designed to do that, IMO.

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
 
Old October 3rd, 2005, 11:06 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 385
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I do a lot of crystal with SQL. What you want to do for each report is figure what is the minimum level of detail you need on the report. Make sure all the filtering of data is done on the SQL side. For example if you filter on state, the result set from sql should only return one states data. Thus every row of data you send from the Stored Procedure is used and displayed on the crystal report (this assumes your not doing complex crystal drill down reports then you will likely have to do the most granular data). If the report is only doing an agregation with no detail. Agregate it on the SQL side not on Crystal. Crystal reports can take for ever if you send it more sql data than it needs. If the report requires detail and you also do agregation well you have to send the detail so you generally can't do the agregation on the SQL side. Sometimes I have writen stored procs that have a parameter to identify if the report as requested was agregated or detailed. Depending on the parameter the stored proc returns detailed rows or just agreagation. The catch here is the structure of your result set can not change between the two different options. Basically I am agreeing with Jeff Mason above but just giving you a little more details and thoughts. Hope this helps.

 
Old October 3rd, 2005, 04:40 PM
Authorized User
 
Join Date: Sep 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for a detailed answer, I have been reworking my query which originally took 47 seconds using method 2 (one big sql script in a SP), this was passing say around 50,000 records to just display less than a 1000 aggregated rows. A long time I know.

Therefore I started again, breaking the large resultset into smaller resultset (using temp tables)

In all the reworked version took 4 temp tables and one query to join them at the end (in one SP), using method 1. The new time is now 7 seconds!!! for the query to run and display the CR.

I hope you can understand my joy here more than my wife did, when I tried to explain my day to her. :-)

Many thanks for the pointers
 
Old October 3rd, 2005, 04:59 PM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 385
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No problem I have had to do the same type of things many times with Crystal/MS-SQL or Oracle. If your stored proce only returns the final 1000 agregated rows your going in the right dirction to streamline your query/process. SQL is infinitely better at quickly handeling data agrgations, complex joins, etc. than Crystal is.






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to pass parameter value to CR SQL Command vijaykumartaduri BOOK: Professional Crystal Reports for VS.NET 3 July 31st, 2007 12:13 AM
summing column values hydriswall PHP Databases 1 December 8th, 2006 04:54 AM
Summing values swwallace XSLT 4 March 4th, 2006 12:13 PM
Summing up in a loop Tschuri XSLT 0 May 3rd, 2005 07:16 AM
Summing and Exporting imhotep666 Excel VBA 3 August 18th, 2004 11:25 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.