SSRS linked server to MySQL parameter problems

  • In SSRS 2008, I have a linked server setup to SugarCRM using the 64 bit Mysql ODBC connector. Openquery is not needed (and does not work) when setting up the query for the dataset. The query you define is passed directly to MySQL.

    Example:

    SELECT userid,state FROM SugarUsersTable WHERE state = 'MD'

    This works fine. What doesn't work is attempting to pass any variable from SSRS to it.

    This does not work:

    SELECT userid,state FROM SugarUsersTable WHERE state = '@state'

    This is very frustrating and I have not been able to find an alternate solution. I need this to be available via the SSRS reports menu for our Sales staff.

  • kmiles (10/20/2012)


    In SSRS 2008, I have a linked server setup to SugarCRM using the 64 bit Mysql ODBC connector. Openquery is not needed (and does not work) when setting up the query for the dataset. The query you define is passed directly to MySQL.

    Example:

    SELECT userid,state FROM SugarUsersTable WHERE state = 'MD'

    This works fine. What doesn't work is attempting to pass any variable from SSRS to it.

    This does not work:

    SELECT userid,state FROM SugarUsersTable WHERE state = '@state'

    This is very frustrating and I have not been able to find an alternate solution. I need this to be available via the SSRS reports menu for our Sales staff.

    What is the error you're getting? Is it returning no rows? Have you tried w/o the ticks/single quotes?

    SELECT userid,state FROM SugarUsersTable WHERE state = @state

    At a previous company we used SugarCRM on MySQL db and our reporting came out of SQL Server. I created a nightly job that pulled the data from the production MySQL db and populated the reporting db in SQL Server. It made reporting easier.

    HTH,

    Rob

  • It returns no rows, with no errors, when passing the parameter. I tried it also without the quotes and nothing changed. I may have to do as you suggested and make a local SQL copy but our SugarCRM database is pretty large and I was hoping to avoid the duplication.

    Thanks for input Rob.

  • kmiles (10/21/2012)


    It returns no rows, with no errors, when passing the parameter. I tried it also without the quotes and nothing changed. I may have to do as you suggested and make a local SQL copy but our SugarCRM database is pretty large and I was hoping to avoid the duplication.

    One "work-around" I can think of is that you can build the expression for the query in SSRS dynamically (using the 'fx' button next to the expression box).

    So instead of passing the parameters, you could build an expression that embeds the parameters in the query.

    Would that solve your problem?

    -----------------
    ... Then again, I could be totally wrong! Check the answer.
    Check out posting guidelines here for faster more precise answers[/url].

    I believe in Codd
    ... and Thinknook is my Chamber of Understanding

  • That seemed like it would be a great solution but nothing is being evaluated prior to sending the query text directly to MySQL. Even typing in the expression box for the dataset query ="select..." returns a MySQL syntax error that it doesn't understand the beginning ="

    This would explain why the parameters are not working becasue SSRS is not evaluation the @param, it's just sending the text "@param".

    Thanks for the help, any other thoughts?

  • ib.naji (10/21/2012)


    kmiles (10/21/2012)


    It returns no rows, with no errors, when passing the parameter. I tried it also without the quotes and nothing changed. I may have to do as you suggested and make a local SQL copy but our SugarCRM database is pretty large and I was hoping to avoid the duplication.

    One "work-around" I can think of is that you can build the expression for the query in SSRS dynamically (using the 'fx' button next to the expression box).

    So instead of passing the parameters, you could build an expression that embeds the parameters in the query.

    Would that solve your problem?

    Using the filter option in the dataset worked. I was typing "@parameter" in the filter field instead of "=Parameters!State.Value". Thanks for your help!

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply