首页 > 解决方案 > 将(sql)数据类型varchar转换为float时出错...但没有什么是float

问题描述

我有一个存储过程,其中没有任何源,也没有任何目标,也没有任何参与将内容连接到源中的列,列的数据类型为 float。但是当我尝试运行它时,我得到了

将数据类型 varchar 转换为浮点数时出错。

我浏览了源代码中引用的每一列,并注释掉试图找出它试图转换的东西,但它似乎总是给出相同的信息。

据我所知,我的专栏都是varchar(255)or 。int

with temp_mart as (
    select 
    ca.YearMonth as Date,
    s.ID as SurveyID,
    t.TeamName as Team,
    q.MetricID,
--  cast(C.City as varchar(255)) as City,
    r.Role,
    QR.QuestionID,
    QR.ID as QuestionResponseID,
    QR.Rating,
    QR.OpenResponse,
    QT.ID as QuestionTypeID
from QuestionResponses QR
join lkup.Questions Q on Q.QuestionID=QR.QuestionID
join lkup.Teams T on t.id=Q.TeamID
join lkup.Surveys S on s.id=q.SurveyID
join lkup.Calendar ca on ca.id=s.ValidFromID
join Responses RE on RE.Qualtrics_ID=QR.Qualtrics_ID
join lkup.Roles R on r.id=re.roleID
join lkup.Cities C on c.id=re.cityID
join lkup.QuestionType QT on QT.ID=Q.QuestionTypeID
where (select count(cityid) from responses) > 3
)
merge DataMart as target
using temp_mart as source
on (source.QuestionResponseID = target.QuestionResponseID)
when matched then update 
set 
    target.Rating=source.Rating,
    target.OpenResponse=source.OpenResponse
when not matched by target
    then insert (
            Date, 
            SurveyID, 
            Team,
            MetricID,
            -- City
            Role, 
            QuestionID, 
            QuestionResponseID,
            Rating,
            OpenResponse,
            QuestionTypeID)
        values (
            source.Date, 
            source.SurveyID, 
            source.Team, 
            source.MetricID, 
            --source.City, 
            source.Role, 
            source.QuestionID, 
            source.QuestionResponseID, 
            source.Rating, 
            source.OpenResponse,
            source.QuestionTypeID)

标签: sql-server

解决方案


推荐阅读