Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

failed to convert parameter value from a string to a double Expand / Collapse
Author
Message
Posted Wednesday, March 5, 2014 9:08 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, March 6, 2014 3:57 AM
Points: 12, Visits: 24
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
Post #1547871
Posted Wednesday, March 5, 2014 10:13 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Thursday, July 24, 2014 9:07 AM
Points: 11,157, Visits: 12,899
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



Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Post #1547920
Posted Wednesday, March 12, 2014 1:50 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, March 12, 2014 3:18 AM
Points: 1, Visits: 1
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
Post #1550048
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse