Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Import SQL statement Post Reply Post New Topic
Author Message
johnkret
Newbie
Newbie
Avatar

Joined: 14 Nov 2008
Location: United States
Online Status: Offline
Posts: 12
Quote johnkret Replybullet Topic: Import SQL statement
     Posted: 05 Mar 2009 at 1:00pm
QuestionErmm

Is there a way to import an SQL statement into Crystal? I've got a pretty complex SQL that I would like my users to run via Crystal.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 09 Mar 2009 at 6:23am
Why not create the sql as a stored proc, and have Crystal run off the stored proc?  It will give you the most versatility in the report as you can do things in a stored proc, that Crystal can't handle.
 
Long ago, I think messed with the Sql statement when I viewed the 'Show SQL statement'....but I use stored procs and XML recordsets now, so I might be full of hot air.
 
Hope this helps
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 09 Mar 2009 at 11:34am
If you're running off of a client/server database (MS SQL Server, Oracle, etc.) then you can add a "Command" in Crystal that contains the SQL.
 
In Crystal, connect to your database.  Under the name of the connected database there may be an option to "Add Command".  If it's there, that's where you put the SQL.  If it's not, then the option is not available for your database.
 
If you're using parameters with your SQL, DO NOT create them in the main report!  Create them in the screen where you add your SQL.  Then, instead of using the "&param" or ":param" syntax, use the Crystal parameter syntax ("{?param}") in your SQL.  The parameters you create here will automatically be created in the main report.  If you create them in the main report first, they don't connect to the command correctly.
 
-Dell 
IP IP Logged
johnkret
Newbie
Newbie
Avatar

Joined: 14 Nov 2008
Location: United States
Online Status: Offline
Posts: 12
Quote johnkret Replybullet Posted: 09 Mar 2009 at 11:36am
Great. When I get a moment I'll try your suggestion. 
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum