ALTER PROC [dbo].[spIVDiscre]
@Value varchar(10) = '1,2'
as
BEGIN
SELECT
'0' as Value ,
pn.No_,
[Address Code] = pn.[Address Code],
[Contact] = pn.[Phone No_],
[Partner Name] = pn.[Name],
[Partner Name 2] = pn.[Name 2],
[PledgeType] = pdl.[PledgeType],
[Address] = pn.[Address]
INTO #Temp110
FROM dbo.[Product Line] pdl WITH (NOLOCK)
INNER JOIN [Pledges] pl WITH (NOLOCK)
ON pdl.[Pledge ID]=pl.ID
LEFT JOIN [dbo].[Contact] pn with (NOLOCK)
on pdl.[No_] = pn.No_
LEFT join [dbo].[Country_Region] co WITH (NOLOCK)
on pn.[Country_Region Code] = co.Code
LEFT JOIN
(
SELECT
cast(Value as int) as Code,
Value2 as Description
FROM Config WITH (NOLOCK)
WHERE
Category='Children'
AND SubCategory='Status'
AND DATEDIFF(dd,GETDATE(),ISNULL(ObsoleteDate,DATEADD(dd,1,GETDATE())))>0
) childstatus
on c.StatusID = childstatus.Code
END
--------------------------------------- @ListA------------------------------------------
IF @Value='1' --ListA
BEGIN
INSERT INTO #Temp110
SELECT
--iList = CAST (@iList as int ) ,
@Value as Value ,
pn.No_,
[Address Code] = pn.[Address Code],
[Contact] = pn.[Phone No_],
[Partner Name] = pn.[Name],
[Partner Name 2] = pn.[Name 2],
[PledgeType] = pdl.[PledgeType],
[Address] = pn.[Address]
FROM dbo.[Product Line] pdl WITH (NOLOCK)
INNER JOIN [Pledges] pl WITH (NOLOCK)
ON pdl.[Pledge ID]=pl.ID
LEFT JOIN [dbo].[Contact] pn with (NOLOCK)
on pdl.[No_] = pn.No_
LEFT join [dbo].[Country_Region] co WITH (NOLOCK)
on pn.[Country_Region Code] = co.Code
LEFT JOIN
(
SELECT
cast(Value as int) as Code,
Value2 as Description
FROM Config WITH (NOLOCK)
WHERE
Category='Children'
AND SubCategory='Status'
AND DATEDIFF(dd,GETDATE(),ISNULL(ObsoleteDate,DATEADD(dd,1,GETDATE())))>0
) childstatus
on c.StatusID = childstatus.Code
WHERE
(pdl.[Pledge Status] = '2' and c.StatusID ='4')
or (pdl.[Pledge Status] = '2' and c.StatusID ='7')
END
-------------ListB---------------------
IF @Value='2' --ListB
BEGIN
INSERT INTO #Temp110
SELECT
--iList = CAST (@iList as int ) ,
@Value as Value ,
pn.No_,
[Address Code] = pn.[Address Code],
[Contact] = pn.[Phone No_],
[Partner Name] = pn.[Name],
[Partner Name 2] = pn.[Name 2],
[PledgeType] = pdl.[PledgeType],
[Address] = pn.[Address]
FROM dbo.[Product Line] pdl WITH (NOLOCK)
INNER JOIN [Pledges] pl WITH (NOLOCK)
ON pdl.[Pledge ID]=pl.ID
LEFT JOIN [dbo].[Contact] pn with (NOLOCK)
on pdl.[No_] = pn.No_
LEFT join [dbo].[Country_Region] co WITH (NOLOCK)
on pn.[Country_Region Code] = co.Code
LEFT JOIN
(
SELECT
cast(Value as int) as Code,
Value as Description
FROM Config WITH (NOLOCK)
WHERE
Category='Children'
AND SubCategory='Status'
AND DATEDIFF(dd,GETDATE(),ISNULL(ObsoleteDate,DATEADD(dd,1,GETDATE())))>0
) childstatus
on c.StatusID = childstatus.Code
WHERE
(pdl.[Pledge Status] = '2' and c.StatusID ='3')
or (pdl.[Pledge Status] = '2' and c.StatusID ='6')
END
select * from #Temp110
where Value in (select Value2 from [fnDiscre] ('1,2,3', ','))
this is SPLIT() function
Alter FUNCTION [dbo].[fnIVDiscre]
( @string varchar(4000))
Returns
@Result Table (Value varchar(100))
As
Begin
declare @len int, @loc int = 1
While @loc <= len(@string)
Begin
Set @len = CHARINDEX(',', @string, @loc) - @loc
If @Len < 0 Set @Len = len(@string)
Insert Into @Result Values (SUBSTRING(@string,@loc,@len))
Set @loc = @loc + @len + 1
End
Return
End
I have a parameter @Value and set its value in the Dataset to =Join(Parameters!Value.Value,",").
it works whenever the user selects one Value , but doesn't work at all whenever multiple Value are selected. It runs, but it doesn't display any data. For example, if I select 'Value 1', it shows 'Value 1' info. But if I select 'Value 1' and 'Value 2 ', nothing shows up.
any ideas why this isn't working? thank so much