Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query MS SQL from Crystal Reports takes a longtime

Status
Not open for further replies.

cyrun

Technical User
Oct 2, 2001
7
0
0
We have many complex reports accessing MS SQL and it seems to take more time than when we are accessing the data from our GUI. Any suggestions on optimizing how Crystal processes SQL data.

Thanks,
 
Make sure that the SQL is passed to the database, do so by cusing the Database->Show SQL Query.

Stored procedures will net the best performance, in which case the pass through isn't a concern.

If you're going to use tables or views directly, use the following guide:

Never use a variable in any formula that will be referenced by the record selection criteria.

When using parameters (parms) in the record selection criteria (this example has a 'All' hardcoded into the default selection of the parm, and the parm is a multiple selection, so I code for it):

(if {?Node}[1] <> 'All'
and {?Node}[1] <> ''
then
({MyTable.MyField} in {?Node})
else
if {?Node}[1] = 'All'
or {?Node}[1] = ''
then
true)

This can be overkill, but this format is the most consistent at passing the SQL, I explicitly handle the IF and the ELSE.

When using dates:

(
({MyTable.MyDate} >= currentdate-10)
and
({MyTable.MyDate} <= currentdate-1)
)

Note the parens around each part of the record selction criteria.

Hope this helps.

Post some specifics if you'd like more specific help, as in the record selection criteria and the current SQL being generated.

-k kai@informeddatadecisions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top