?
Solved

How do I use a multivalue parameter on SQL Server command window in Crystal Reports 2008?

Posted on 2011-09-13
5
Medium Priority
?
251 Views
Last Modified: 2012-06-27
Hello,

I'm using a SQL command window in Crystal 2008 as the data source for my report. I've checked the box in the command parameter window to "allow multiple values" but I'm getting an error message when I use mulitple parameters.

Below is a simplified version of my sql code:

declare @Company as varchar(4);
set @Company = {?Company}   ----  {?Company} is the multivalue parameter

select c.company_id, c.description, c.ownership_pct
from company c
where c.company_id = {?Company}


Do I need to change the syntax of my query when using the "allow muliple values" feature? I've tried changing the code to "where c.company_id in {?Company}" but I continue to get the attached error message.

Any ideas on how to get past this error?

Thanks!
David
 Crystal Reports Error Message
0
Comment
Question by:dking_wri
  • 2
  • 2
5 Comments
 
LVL 101

Accepted Solution

by:
mlmcc earned 1600 total points
ID: 36530857
The multiple values is for parameters you build through the ADD PARAMETER button in the command window.  It is not for parameters you declare in that way.

Why are you using the SET, that is declaring a parameter in the command.  Try deleting that line

mlmcc
0
 
LVL 77

Assisted Solution

by:peter57r
peter57r earned 400 total points
ID: 36530908
I would use IN rather than =
0
 

Author Comment

by:dking_wri
ID: 36531844
Hi mlmcc,

I'm using SET as I have repeated the variable multiple times in the actual code. But I think I'm following your question. Maybe I should replace every instance of the @company with the Crystal equivalent  {?Company}. Let me try that and I'll get back to you.

Hi peter57r,

I did use the IN function when I first encountered the error. I'll try this again in combination with mlmcc comment and get back to you.

Thanks again,
David
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 36532351
You declared @Company s a VARCHAR(4), it can't have multiple values.

mlmcc
0
 

Author Closing Comment

by:dking_wri
ID: 36532382
Thanks for the help. I replaced my declared SQL variable with the Crystal Parameter and it worked.

I used the IN statement again, but this time I removed the parenthesis and was able to get the report to run as expected.

Thanks again for your time and input!!

David
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month14 days, 3 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question