当前位置: 代码迷 >> Sql Server >> 将数据类型varchar转换为float时出错!该如何解决
  详细解决方案

将数据类型varchar转换为float时出错!该如何解决

热度:43   发布时间:2016-04-27 15:23:18.0
将数据类型varchar转换为float时出错!
SELECT   ID,  
            ' <iframe   marginWidth= "0 "   marginHeight= "0 "   src= "http://www.mcq.com.cn/lianxi_geren1818.aspx?id= '
              +   ID   +   ' "                           frameBorder= "0 "   width= "28 "   scrolling= "no "   height= "24 "   style= "WIDTH:   28px;   HEIGHT:   24px "   align= "left "   valign= "top "> </iframe> '
              AS   icc
FROM   dbo.CompanyTable

其中CompanyTable表中的ID类型是float,上面的语句运行时会出现:将数据类型varchar转换为float时出错!

请问大家怎么解决?

------解决方案--------------------
SELECT ID,
' <iframe marginWidth= "0 " marginHeight= "0 " src= "http://www.mcq.com.cn/lianxi_geren1818.aspx?id= '
+ cast(ID as varchar(50)) + ' " frameBorder= "0 " width= "28 " scrolling= "no " height= "24 " style= "WIDTH: 28px; HEIGHT: 24px " align= "left " valign= "top "> </iframe> '
AS icc
FROM dbo.CompanyTable

------解决方案--------------------
SELECT ID,
' <iframe marginWidth= "0 " marginHeight= "0 " src= "http://www.mcq.com.cn/lianxi_geren1818.aspx?id= '
+ cast(ID as varchar) + ' " frameBorder= "0 " width= "28 " scrolling= "no " height= "24 " style= "WIDTH: 28px; HEIGHT: 24px " align= "left " valign= "top "> </iframe> '
AS icc
FROM dbo.CompanyTable
  相关解决方案