Pass Crystal formula result to Stored Proc and use in 'where' stmt (1 Viewer)

akwewe

New member
Local time
Yesterday, 18:24
Joined
Jan 23, 2009
Messages
1
Crystal 8.5, SQL Server 2000
I have a main report that has a formula that returns the string of state codes that I captured from a Crystal Parameter. It's named @StringOfStates. I also have this value saved to a shared stringvar, @varSTATES. Then, I pass @varSTATES to the subreport.
The subreport datasource is the Stored Procedure below. In the subreport I now have two parameters. One is Pm-@varSTATES from the main report. The other is @STATE_CODE from the SP below.
Create procedure rpt_Emergency
@STATE_CODE varchar(255)
AS
Create table #Emergency...
Insert into #Emergency...
Select ....
From ....
Where MyTable.STATE in ('VA','MD','DC')
I need to change the last line in the SP so that it pulls the value from Pm-@varSTATES instead of having ('VA','MD','DC') hard coded.
If I change the syntax to
Where MyTable.STATE in @varSTATES I get an error stating "Must declare the variable @varSTATES."
I guess what I'm asking is 'how do I get the variable into the SP so I can reference it?'
Thanks!
 

Srinvb

Registered User.
Local time
Today, 06:54
Joined
May 25, 2009
Messages
10
Try this
since you already have the string of states @StringOfStates ( i assume you build this from multiselect parameter using the JOIN Function),
then change the subreport links select the @StringOfStates as the mainreport join condition from the subreport @STATE_CODE as the
join condition.check the result.
 

Users who are viewing this thread

Top Bottom