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