Problem with Calculated Field

Jan 4, 2010 at 8:51 PM

I am trying to bring over a calculated number field from sharepoint.  When what I think the mapping should be:

<Field Name="Hours" SqlType="decimal(12,2)" SPType="Number" Required="false"></Field>

I get an error: System.Data.SqlClient.SqlException: Incorrect syntax near '#0'

So I setup the SQL type to varchar and the value of the Hours sharepoint field is, float;#0.5000000, or something like that. 

Is there another SPtype I should be using for this?

Jan 6, 2010 at 3:23 PM

The question is what is the calculated column for?  Generally calculated columns in SharePoint are purely for presentation of data you have in that list.  What you want to slam then is the source data and whatever calculation you need to do you can very easily do in SQL in a, more likely, elegant or useful way than you might be doing with SharePoint (most of the time I realize this is the case with dates in calculated fields).  In any case, it is generally the case that if you want to slam a calculated column, you probably don't need to.  Otherwise you need to slam it as a varchar as you tried, which then you can manipulate in the UI of whatever is using the SLAM data.  But in this situation, I imagine it would be simpler if not desirable to be slamming the source of the calculation only.


Jan 14, 2010 at 9:52 PM

 That makes total sense.  I SLAMed the source data and calculated it in SQL.  Thanks for the suggestion.