Convert variable varchar value to float

  • Hi All,

    i hd doubt regarding casting ihd error mssglike

    Error converting varchar to float my query below

    ALTER Proc SP_Get_LeaveStatistics

    (

    @UserTypeId uniqueidentifier = null,

    @EmpId uniqueidentifier =null,

    @LeaveStatisticsId uniqueidentifier = null,

    @LeaveTypeId uniqueidentifier = null,

    @FromYear datetime = null,

    @ToYear datetime = null,

    @Granted float = -2,

    @AlreadyUsed float = -2,

    @CurrentMaxCarry float = -2,

    @CurrentMaxEncash float = -2,

    @ModifiedBy uniqueidentifier = null,

    @ModifiedDate datetime = null,

    @Flag int = 1

    )

    As

    Declare @qrystr varchar(8000)

    Declare @Leavedetails float

    Begin

    set @Leavedetails = 10

    Set @qrystr = 'Select case: when tbl_UserTypeMaster.UserType = ''Service'' then tbl_RankMaster.RankName+'' ''+tbl_EmpMaster.EmpName + '' ''+ tbl_Empmaster.Surname else

    tbl_EmpMaster.EmpName + '' ''+ tbl_Empmaster.Surname +'' ''+ tbl_RankMaster.RankName end ''Name'',tbl_LeaveTypeMaster.LeaveType,tbl_LeaveStatistics.LeaveStatisticsId,

    tbl_LeaveStatistics.EmpId, tbl_LeaveStatistics.LeaveTypeId,tbl_LeaveStatistics.FromYear,tbl_LeaveStatistics.ToYear,

    (tbl_LeaveStatistics.Granted - isnull(tbl_LeaveStatistics.AlreadyUsed,0) - @Leavedetails) ''NoofDays'',tbl_LeaveStatistics.Granted,isnull(tbl_LeaveStatistics.AlreadyUsed,0) ''AlreadyUsed'',

    tbl_LeaveStatistics.CurrentMaxCarry,tbl_LeaveStatistics.CurrentMaxEncash,tbl_LeaveStatistics.ModifiedBy,tbl_LeaveStatistics.ModifiedDate,

    tbl_LeaveStatistics.Flag

    from

    tbl_LeaveStatistics,tbl_leavedetails,tbl_LeaveTypeMaster,tbl_EmpMaster,tbl_UserTypeMaster,tbl_RankMaster

    ihd doubt in line i copy & past below

    (tbl_LeaveStatistics.Granted - isnull(tbl_LeaveStatistics.AlreadyUsed,0) - @Leavedetails) ''NoofDays'' hw i need to concanate or cast from varchar to float.

    Regards

    ANAND

  • ihd doubt in line i copy & past below

    (tbl_LeaveStatistics.Granted - isnull(tbl_LeaveStatistics.AlreadyUsed,0) - @Leavedetails) ''NoofDays'' hw i need to concanate or cast from varchar to float.

    What are the data types of the first two columns? tbl_LeaveStatistics.Granted,tbl_LeaveStatistics.AlreadyUsed

    ---------------------------------------------------------------------------------

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

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