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 |
|
steelkilt
Constraint Violating Yak Guru
255 Posts |
Posted - 2004-06-04 : 16:53:28
|
| I'm trying to update col1 in a temp table (#data_holder) with concatenated columns from a base table (master_table -- columns are PRIME and PLANTVALUE), with PLANTVALUE being placed in parentheses. Final format for a value in #data_holder.col1 would be:1.075 (0.678)master_table contains many entries that look like floats, i.e. 0.0035 etc., but all datatypes in master_table are varchar.Here's the key code:update #data_holderSET #data_holder.col1 = master_table.prime + '(' + master_table.plantvalue + ')' from #data_holder, master_tableWHERE master_table.ID < 500 each time I run the update I get the error:"error converting datatype varchar to float"as noted, datatypes in master_table are varchar across the board. Any idea on correct syntax?thx |
|
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2004-06-04 : 16:55:45
|
| What is the datatype of #data_holder.col1 ?You might have to CAST master_table.prime and master_table.plantvalue to VARCHAR's. An implicit conversion might be taking place.Michael<Yoda>Use the Search page you must. Find the answer you will.</Yoda> |
 |
|
|
steelkilt
Constraint Violating Yak Guru
255 Posts |
Posted - 2004-06-04 : 17:04:30
|
| eureka!good eye Michael. Too much time spent at the bottom of the script in QA. At the very top I see that I data typed everything as a float for the temp table. Change to varchar fixes it. |
 |
|
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2004-06-04 : 17:29:10
|
| <Yoda>A fresh set of eyes, clear they are.</Yoda><Yoda>Use the Search page you must. Find the answer you will.</Yoda> |
 |
|
|
|
|
|