I would write the stored proc to use the quantity in the database and thus be automatic.
for this issue, the hard part is creating the number of row that you need...
maybe...
select itemNumber, quantity into #list from someTable
select * into #label from #list where quantity > 0 --initialize the table
while (select SUM(COUNT(*) - Quantity from #labels group by itemNumber) > 0
insert #label
select *
from #label l
join (select itemNumber, COUNT(*) AS Current from #labels group by itemNumber) ss ON ss.itemNumber = l.itemNumber
where ss.Current < l.quantity
select * from #label order by itemNumber
there are lots of sites to help guide you building a stored proc, which is a bit out of the realm for this forum. The above, should, create a table with the itemNumber (and quantity) repeated as many times as Quantity says to.
I haven't tested it, but I think it would work. you would want to replace the names that I used with the actual names from the database, and any other information that you would want displayed on the label, the above just shows how to generate the multiple rows.
As to the help in Crystal, what it is saying is that if the stored proc takes any parameters (and your may or may not, they are not required) then Crystal will automatically build a parameter and pass it to the stored proc when your report is run. Your user will have to assign a value to the parameter (because your store proc needs it), so Crystal is just helping you out by building the parameter.
Hope this helps you out. Knowing SQL, I think, really makes Crystal that much simpler, just because YOU can select/manipulate the data before Crystal ever sees it, which can make a complex report, just a bit easier, as much of the complexity might have been moved to the stored proc.
Good Luck
|