使用临时表删除硬编码值时出现问题
首先祝大家新年快乐。我在编写查询时遇到问题。执行查询时出现错误。
查询:
select case
when S.R1 = '6' then 5
when S.R1 = '7' then 6
when S.R1 = '8' then 7
when S.R1 = '9' then 8
when S.R1 ='10' then 9
else S.R1 end as Q
FROM [HelpService].[dbo].[help] s
-----------------------------------------------
SELECT [Source], [Score]
INTO #Temp_Q
FROM [HelpDesk].[dbo].[Survey]
WHERE [data_Source Name] = 'Text Data'
-----------------------------------------------
select CONVERT(REAL, a.[Dell Score]) as Q
FROM [HelpService].[dbo].[help] s
LEFT OUTER JOIN #CE_Temp_Q a on
s.[R1] = a.[Source]
错误
消息 8114,级别 16,状态 5,第 1
行将数据类型 varchar 转换为 real 时出错。
我被要求做的是我需要删除硬编码值并需要使用临时表编写查询。
提前致谢, 沙斯拉
First of all Wish u all Happy New Year. I have a problem in writing query. While executing my query I am getting an error.
Query:
select case
when S.R1 = '6' then 5
when S.R1 = '7' then 6
when S.R1 = '8' then 7
when S.R1 = '9' then 8
when S.R1 ='10' then 9
else S.R1 end as Q
FROM [HelpService].[dbo].[help] s
-----------------------------------------------
SELECT [Source], [Score]
INTO #Temp_Q
FROM [HelpDesk].[dbo].[Survey]
WHERE [data_Source Name] = 'Text Data'
-----------------------------------------------
select CONVERT(REAL, a.[Dell Score]) as Q
FROM [HelpService].[dbo].[help] s
LEFT OUTER JOIN #CE_Temp_Q a on
s.[R1] = a.[Source]
ERROR
Msg 8114, Level 16, State 5, Line 1
Error converting data type varchar to real.
What I am asked to do is I need to remove the hard coded values and need to write queries with a temp table.
Thanks in Advance,
Shashra
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这意味着您的值之一包含非数字的内容。
例如以下工作正常
但是以下任一操作都会产生与您遇到的相同错误
更新
有时问题值并不那么明显
尝试以下操作来查找它
或
This means one of your values contains somthing that isn't a Number.
For example the following works fine
But either of the following will yield the same error you are getting
UPDATE
Sometimes its not so obvious what the problem values are
Try the following to find it
OR
以下查询返回什么?
What does the following query return?