Avatar of tanj1035
tanj1035
 asked on

SSRS, how to let the user manually input the value in a table (not by the parameter method)

hi Experts,

The user wants to manually input the business contract No. up to 50 in table A. Table B will be called based on how many business contract no. was input in table A. For example, If the user input 5 business contract no. in table A,  then the table B will show the related data for those 5 business contract no.

We do not want to do it by parameter, since 50 is too much.

Thank you,
SSRS

Avatar of undefined
Last Comment
tanj1035

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Arifhusen Ansari

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
tanj1035

ASKER
hi Arif, Thanks for your reply. If I do the function split & parameter approach.
I have encounter the issues.  The stored procedure only returned the top 4 rows of data. If I input 5 contract strings or 50 contract strings, it only returned top 4 contract string data. Do you have any suggestions? Thank you.

The data type of contract strings is varchar.  They are displayed as
Contract String
193-859655
193-859616
193-859331
193-859187

Those are my code below


CREATE  FUNCTION [dbo].[Split]
(
	@List nvarchar(2000),
	@SplitOn nvarchar(5)
)  
RETURNS @RtnValue table 
(
		
	Id int identity(1,1),
	Value nvarchar(100)
) 
AS  
BEGIN

While (Charindex(@SplitOn,@List)>0)
Begin 
Insert Into @RtnValue (value)
Select 
    Value = ltrim(rtrim(Substring(@List,1,Charindex(@SplitOn,@List)-1))) 
Set @List = Substring(@List,Charindex(@SplitOn,@List)+len(@SplitOn),len(@List))
End 
Insert Into @RtnValue (Value)
    Select Value = ltrim(rtrim(@List))

    Return
END


GO

Open in new window



create procedure [dbo].[sp_rept_TitleLoan_AuctionSalesSummaryByContract]
@Contract varchar(50)
               
                 
/******************************************************************
Created by:            Joy Tan
Created on:            7/20/2016
Description:      For the report Auction Sales Summary By Contract

*******************************************************************/


As

Begin

--Set DATEFIRST 2

--declare @ReportDate datetime
--Set @ReportDate=DateAdd(d,-1,Convert(char(10),GETDATE(), 101))


SELECT StoreName,VendorName, LoanStoreID,ContractString,CustomerLastName + ', '+ CustomerFirstName as CustomerName,AuctionLetterExpDate,AuctionDate,LoanAmountFinanced,OPB,
      ISNULL(AutomobileBlackBookValue,0) AS BBV,AuctionSaleAmount,RepoFee,(AuctionExpense+AuctionMiscExpense) AS OtherExpenses,
      AuctionCheckAmount,(AuctionCheckAmount-RepoFee) AS GainLoss,AuctionDisposalDate,VPName,AMName
FROM (

SELECT StoreName, LoanStoreID,ContractString,CustomerFirstName,CustomerLastName,AuctionLetterExpDate,AuctionDate,LoanAmountFinanced
,case when VendorName is null then 'Not Entered' else vendorname end  as VendorName,
            (SELECT SUM(TransactionPrincPaid) FROM tblReportingTransactions WHERE tblLoans.LoanID=tblReportingTransactions.LoanID AND TransactionDate>=tblLoans.AuctionDate AND TransactionTypeID IN (1,2,3,9,11)) AS OPB,
            AutomobileBlackBookValue,AuctionSaleAmount,RepoFee,AuctionExpense,AuctionMiscExpense,AuctionCheckAmount,
            tblVP.UserFirstName+' '+tblVP.UserLastName AS VPName,tblAM.UserFirstName+' '+tblAM.UserLastName AS AMName, AuctionDisposalDate
      FROM tblvendors tblvendors right join
          tblLoans tblloans on tblvendors. vendorid= tblloans.auctionvendorid INNER JOIN
            tblCustomers ON tblLoans.CustomerID=tblCustomers.CustomerID INNER JOIN
            tblAutomobiles ON tblLoans.AssetID=tblAutomobiles.AssetID INNER JOIN
            tblStores ON tblLoans.LoanStoreID=tblStores.StoreID INNER JOIN
            tblUsers tblVP ON tblStores.vpID=tblVP.UserID INNER JOIN
            tblUsers tblAM ON tblStores.amID=tblAM.UserID
      WHERE
            AssetTypeID=1
            AND LoanStatusID=2
            AND  CONTRACTSTRING  IN (select value from [dbo].[Split] (@Contract, ','))
            )tblDisposal
ORDER BY VPName,AMName, LoanStoreID

End


GO

exec sp_rept_TitleLoan_AuctionSalesSummaryByContract
'193-859655,193-859616,193-859331,193-859187,193-859637,216-866100,216-866023'

Open in new window

tanj1035

ASKER
I have changed @Contract varchar(50) to @Contract varchar(max). It can return me 46 rows, but still not 50 rows.  Does (max) still have limitation?

Thanks.
Arifhusen Ansari

You query might return the max 46 record only.

Try to run the query with out @Contract filter. So you come to know how number of rows are available.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
tanj1035

ASKER
What I changed

@Contract varchar(50) to @Contract nvarchar(4000). Now, it can return 5o rows. Thank you,  Arif,