RUA Volunteer2?
asked on
SQL Server & SSRS working with parameters and multiple select values.
I think I need to use some variant of the split function or string_split or the c_split.
IN the SQL Stored Procedure I have declared the value
@location_code varchar (100)
I have referenced it in a table. l_location. The table is joined on.
and I have it in the where clause ...AND ..tbl.location_code in (@location_code)
When the report runs in SSRS the lookup values show up and they can be selected individually or in multiples. Currently I can only select one value and it runs. If I select 2 or more the report shows no results but runs. That is why I think that I need to use split somewhere. I have tried many different ways and none of them worked. If anyone knows what I need to make sure I include please advise. Thank you.
IN the SQL Stored Procedure I have declared the value
@location_code varchar (100)
I have referenced it in a table. l_location. The table is joined on.
and I have it in the where clause ...AND ..tbl.location_code in (@location_code)
When the report runs in SSRS the lookup values show up and they can be selected individually or in multiples. Currently I can only select one value and it runs. If I select 2 or more the report shows no results but runs. That is why I think that I need to use split somewhere. I have tried many different ways and none of them worked. If anyone knows what I need to make sure I include please advise. Thank you.
ALTER FUNCTION [dbo].[c_Split]
(
@InputString VARCHAR(MAX)
,@Separator VARCHAR(MAX)
)
RETURNS @ValueTable TABLE (Value VARCHAR(MAX))
AS
BEGIN
DECLARE @SeparatorIndex INT, @TotalLength INT, @StartIndex INT, @Value VARCHAR(MAX)
SET @TotalLength=LEN(@InputString)
SET @StartIndex = 1
IF @Separator IS NULL RETURN
WHILE @StartIndex <= @TotalLength
BEGIN
SET @SeparatorIndex = CHARINDEX(@Separator, @InputString, @StartIndex)
IF @SeparatorIndex > 0
BEGIN
SET @Value = SUBSTRING(@InputString, @StartIndex, @SeparatorIndex-@StartIndex)
SET @StartIndex = @SeparatorIndex + 1
END
ELSE
BEGIN
Set @Value = SUBSTRING(@InputString, @StartIndex, @TotalLength-@StartIndex+1)
SET @StartIndex = @TotalLength+1
END
INSERT INTO @ValueTable
(Value)
VALUES
(@Value)
END
RETURN
END
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.