Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Data type error in SELECT

Author  Topic 

yoi55
Starting Member

2 Posts

Posted - 2012-01-17 : 13:55:37
I am running a SELECT statement and am getting the following error:
Error converting data type varchar to float.

A lot of the fields are the float datatype and I am trying to add characters between some of them. Here is the code:


SELECT tblTank_Information.Tank_Number, tblTank_Information.SAPMaterialCode, tblProduct_Code.Product_Code,
(tblDaily_Gauge_Data.Current_Gauge_Feet + CHAR(39) + CHAR(32) +
tblDaily_Gauge_Data.Current_Gauge_Inches + CHAR(45) +
tblDaily_Gauge_Data.Current_Gauge_Fraction + CHAR(34)) AS Gauge,
(tblTank_Information.Minimum_Gauge_Ft + CHAR(39) + CHAR(32) +
tblTank_Information.Minimum_Gauge_In + CHAR(34)) AS Minimum,
(tblTank_Information.Maximum_Gauge_Ft + CHAR(39) + CHAR(32) +
tblTank_Information.Maximum_Gauge_In + CHAR(34)) AS Maximum,
(CHAR(40) + tblTank_Information.Minimum_Temp_F + CHAR(45) +
tblTank_information.Maximum_Temp_F + CHAR(41)) AS TempRange,
tblDaily_Gauge_Data.Current_Gauge_Date FROM tblTank_Information,
tblDaily_Gauge_Data, tblProduct_Code WHERE
tblTank_Information.Gauging_Area_Code = '17'


What could I do to fix this? Do I have to convert each type to char??

X002548
Not Just a Number

15586 Posts

Posted - 2012-01-17 : 13:58:34
CONVERT(varchar(25),tblDaily_Gauge_Data.Current_Gauge_Feet) + CHAR(39) + CHAR(32) +

for example

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

yoi55
Starting Member

2 Posts

Posted - 2012-01-17 : 14:10:17
Ok, that works perfectly. Thanks a lot
Go to Top of Page
   

- Advertisement -