views:

425

answers:

0

I have a static list of user names as a parameter in CR2008. I want to be able to use CR syntax to add database values to the users selected and query using that.

For instance, if the report runner selects Doe, John from my list of parameters, I need to query the database using something like

If {?prmUsers} = "Doe, John" then variableA = "doejoh" And variableB = "[email protected]"

And the select would be something like:

Declare @BeginDate SmallDateTime
Declare @EndDate SmallDateTime
Set @BeginDate = '2009-01-19'
Set @EndDate = '2009-01-23'

SELECT DISTINCT
    DateTime,
    [Recipient-Address],
    [Message-Subject],
    [Sender-Address]
FROM
    dbo.Logs
WHERE
    LEFT([Recipient-Address], 6) IN ( 'doejoh' ) OR
    LEFT([Recipient-Address], 10) IN ( 'john.doe@g' )
    AND DateTime BETWEEN @BeginDate + ' 00:00:00' And @EndDate + ' 23:59:59'

Of course, the report runner would be able to select multiple names. Any ideas?