Solved

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

Posted on 2011-09-13
5
236 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 100

Accepted Solution

by:
mlmcc earned 400 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 100 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 100

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

914 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now