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 |
|
rguthrie
Starting Member
6 Posts |
Posted - 2003-03-06 : 17:22:11
|
| I am trying to do an update on a column in a table where I concatanate 4 of the fields in the table. When I run the update statement, I get a "Subquery returned more than 1 value." error.Here's the statement I'm trying to run:update table1set field5 =(selectfield1+field2+field3+field4from table1)How do I handle this situation? I haven't written code using cursors but I am guessing that might be the way to handle this sitaution. Any input is greatly appreciated. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-03-06 : 17:32:24
|
| Why are you using a subquery to do this?Here is what you need:update table1set field5 = field1+field2+field3+field4Tara |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-03-06 : 17:33:43
|
| Just so that you know, when you use a subquery, it can only return one value. So say your subquery were select field1 from table1, well that would only work in a subquery where you only had one record in the table. If you have more than one record in a table, then you would need to add a WHERE clause to the subquery.Tara |
 |
|
|
rguthrie
Starting Member
6 Posts |
Posted - 2003-03-06 : 17:37:14
|
| DUH!! Well that was a simple fix. I don't know what I was thinking -- or lack of thinking I think is the issue! Thanks! |
 |
|
|
|
|
|