failed to convert parameter value from a string to a double

  • I have a stored procedure on a SQL 2005 DB that retrieves data from a mysql DB on another server (none of this was set up by myself)

    The sp is as follows:

    USE [InSightLiveData]

    GO

    /****** Object: StoredProcedure [dbo].[GetHoursWorkedBetweenDates] Script Date: 03/05/2014 15:40:07 ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    --ALTER FUNCTION [dbo].[fn_TestFunc] ( @Adviser int, @InitialDate datetime, @FinalDate datetime ) RETURNS float

    ALTER procedure [dbo].[GetHoursWorkedBetweenDates] (

    @Adviser varchar(10),

    @InitialDate varchar(10),

    @FinalDate varchar(10),

    @hours float out )

    AS

    BEGIN

    --declare @hours float

    declare @sql as nvarchar(1000)

    declare @linkedserversql as nvarchar(1000)

    declare @param_definition as nvarchar(1000)

    -- set @sql = 'call flexi.GetHoursWorkedBetweenDates(''62843'',''2014-01-27'',''2014-02-23'');';

    -- select @hours = total_time_decimal from openquery(fleximysql, @sql );

    --select @hours = total_time_decimal from openquery(fleximysql, 'call flexi.GetHoursWorkedBetweenDates(''62843'',''+ @InitialDate +'',''2014-02-23'');');

    -- the one below works for literal values only

    --select @hours = total_time_decimal from openquery(fleximysql, 'call flexi.GetHoursWorkedBetweenDates(''62843'',''2014-01-27'',''2014-02-23'');');

    --exec('call flexi.GetHoursWorkedBetweenDates(''62843'',''2014-01-27'',''2014-02-23'');') at fleximysql;

    --exec('select ? = count(*) from flexi.work_time', @hours output) at fleximysql;

    --exec('select ? = max(time_worked) from flexi.work_time', @hours output) at fleximysql;

    set @linkedserversql = 'call flexi.GetHoursWorkedBetweenDates('+@adviser+','''+@initialdate+''','''+ @finaldate +''')';

    set @sql = 'select @hoursout = total_time_decimal from openquery(fleximysql, ''' + Replace(@linkedserversql,'''','''''') + ''')'

    set @param_definition = '@hoursout float out'; --, @adviserin varchar(12)' --, @InitialDate datetime, @FinalDate datetime';

    execute sp_executesql @sql, @param_definition, @hoursout=@hours out; --, @adviserin='2014-01-27'; --, @InitialDate, @FinalDate;

    END

    If I run exec('call flexi.GetHoursWorkedBetweenDates(''62843'',''2014-01-27'',''2014-02-23'');') at fleximysql; on the SQL server iot works fine but when I set up a new SSRS report calling the stored procedure I get the error:

    failed to convert parameter value from a string to a double

    When I run the stored procedure in visual studio I have tried all the different ways of entering the values for the dates I can think of but I still get the error.

    I'm not sure why the date parameters in the sp are set as varchars, I can only wonder if it's to be compatible with the mysql DB.

    Thanks

    Annie

  • I'm not really familiar with accessing MySQL from a linked server, but I'd suggest converting the @advisor to a compatible data type when passing it to sp_ExecuteSql

  • The use of flip-flops is believed to cause many pains and injuries, including ankle sprains and broken bones. Some individuals who walk for long periods report pain in the feet, ankles, and lower legs. But it is also not very comfortable and convenient if your foot is enclosed all the time with shoes. Just see the result that heels bring to girls and ladies.

    _______________________________________________

    denim jeans

Viewing 3 posts - 1 through 2 (of 2 total)

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