Dsw Wds
Dsw Wds

Reputation: 502

Error converting data type varchar to float for stored procedure

I have download the zip file which contain the stored procedure for dbo.Chart from the website Here

I have save them into the stored procedure under Programmability.

EXEC dbo.Chart

'SELECT Sales,
x_axis, y_axis
FROM Seed_Number1CoupleIn';

My x-axis is (int) while y-axis is varchar, sales int.

But when I try to run the following code, I get this error:

Msg 8114, Level 16, State 5, Line 1
Error converting data type varchar to float.

My stored procedure dbo.Chart has 500 lines, so if you guys required me to upload here I will do it.

Upvotes: 1

Views: 415

Answers (2)

jatz2012
jatz2012

Reputation: 41

Its written on the site that Your Data Should be in FLOAT.

Making Charts from Your Own Data

here is exact lines from the site.... dbo.chart site

So you have to change your X and Y-Axis column data type to float

Upvotes: 1

Arulkumar
Arulkumar

Reputation: 13237

Form the link, they are clearly documented about the datatype:

Making Charts from Your Own Data

To turn your own data into a line, column, area, or bar chart using the Chart stored procedure, you need to design a SELECT query that serves as the first parameter in the stored procedure call. The SELECT query needs to retrieve data from three columns. The first column needs to provide the series names. Typically, they're text strings, but you can use any data type that's implicitly convertible to a string (e.g., int). The second and third columns need to provide numeric values for the X axis and Y axis, respectively. We recommend using the FLOAT data type.

For example, if you have a table named Sales with the FiscalYear, ProductCategory, and TotalSales columns, you could make a line chart with this call:

EXEC dbo.Chart
'SELECT ProductCategory,
FiscalYear, TotalSales
FROM Sales'; 

So you need to pass the x_axis, y_axis as FLOAT instead of VARCHAR and int

Upvotes: 1

Related Questions