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!

Can you execute a SQL statement from a Crystal Report?

Status
Not open for further replies.

careymw

IS-IT--Management
Oct 8, 2010
41
0
0
US
My company is using Crystal Reports 2008 and we have several SQL statements that update temp tables that the crystal report is going to reference. Is there anyway to set it up so that the SQL can be executed before the report is run? We want to eliminate the need to time things and so we can ensure the temp tables are actually updated. Let me know if you have any suggestions, I appreciate it.
 
You can use stored procedure or command as datasource for Crystal report. Both can execute multiple SQL statements. For example :


SELECT * INTO #Temp FROM ...
UPDATE #Temp ...

SELECT * FROM #Temp


Viewer, scheduler and manager for Crystal reports.
Send you report everywhere.
 
Awesome, this is done within the SQL stored procedure then not within the report. So the initial data connection would be made to the stored procedure and the report would always be up to date. This sounds like it would work. Thanks for the great suggestion.
 
Yes, stored procedure will handle it. If you don't have rights to create SP you may use crystal command which will be created on the reports side. I consider SP as a better choice than the command because it will be compiled and you will be able to check dependencies etc. Crystal command will keep all the report logic in one place , which may be an advantage if you work with different databases.

Viewer, scheduler and manager for Crystal reports.
Send you report everywhere.
 
Thanks everyone...I'll give a run on the stored procedure angle and if that doesn't work out I'll have some other options to try with the UFLs and the crystal command. I appreciate the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top