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.
| Author |
Topic |
|
NickyJ
Starting Member
46 Posts |
Posted - 2006-03-02 : 07:43:48
|
| I'm confused as I have a field with the following in its formula (convert(float,[ContractNumber]) + len([ContractNumber]))Now this table returns an error of Server: Msg 8114, Level 16, State 5, Line 1Error converting data type nvarchar to float.Which I could understand if there were Letters within the above field, but there isn't, whats more confusing is if I run the same T-SQL as per the formula from within Query Analyser :SELECT DISTINCT Contract.ContractID, --ContractSortNo, (convert(float,[ContractNumber]) + len([ContractNumber])) as ContractSortNofrom....then this doesn't return the errorWhat am I missing ?? |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2006-03-02 : 07:49:59
|
1. don't convert to float convert to decimal. float is not a precise data type.2. maybe you have dots or commas at impropper places?Go with the flow & have fun! Else fight the flow |
 |
|
|
NickyJ
Starting Member
46 Posts |
Posted - 2006-03-02 : 08:20:38
|
| Agree with point 1 just not at to me to change, though I'll recommend.Have found the rogue entry and ' within the field, have question why this field is of NVARCHAR datatype as could cause problems.Thanks for help |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-03-02 : 09:23:53
|
| Why did you use NVARCHAR to store contract numbers? Then how do you expect it to convert to float? Give some sample data and expected result. Seems that you want to do concatenationMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|