Quantcast
Channel: Parameters SSRS
Viewing all articles
Browse latest Browse all 36

Parameters SSRS

$
0
0

Hi,

 

If the parameter is a single-value parameter, a workaround is that you can use three datasets to achieve your purpose, for example:

1. Create an additional table to store user selected value, such as: 

CREATE TABLE [dbo].[UserInput](
[RID] [int] IDENTITY(1,1) NOT NULL,
[UserID] [varchar](256) NOT NULL,
[ParameterName] [nvarchar](256) NOT NULL,
[ParameterValue] [nvarchar](max) NULL
)

 

2. Create 3 datasets, one for default values, one for available values, and the 3rd to store user selected values:

A. Available Values

 

SELECT 1 AS ID
UNION ALL
SELECT 2 AS ID
UNION ALL
SELECT 3 AS ID

 

B.Default Values

 

SELECT *
FROM [tempdb].[dbo].[UserInput]
WHERE [UserID]=@UserID AND @ParameterName=[ParameterName]

 

C.To store user selected values

 

IF EXISTS (SELECT 0 
      FROM  [tempdb].[dbo].[UserInput] 
      WHERE [UserID] = @UserID 
         AND @ParameterName = [ParameterName] 
) 
 BEGIN 
UPDATE [tempdb].[dbo].[UserInput]
  SET [ParameterValue] = @ParameterValue
WHERE [UserID] = @UserID AND [ParameterName] = @ParameterName
 END 
ELSE 
 BEGIN 
   INSERT INTO [tempdb].[dbo].[UserInput] 
         ([UserID], 
          [ParameterName], 
          [ParameterValue]) 
   VALUES   (@UserID, 
          @ParameterName, 
          @ParameterValue) 
 END

 

3. Finally, you should make the parameter always refresh data when the parameter changes (2008/R2).

 

Thanks,

Albert Ye


Viewing all articles
Browse latest Browse all 36

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>