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 |
|
tsqlnewbie
Starting Member
2 Posts |
Posted - 2002-11-21 : 06:59:36
|
Hi, i need help..I have a this table with these values,col1 col2 col3 value111 222 333 1112 222 333 2113 222 333 3114 222 333 4111 444 555 null112 444 555 null113 444 555 114 444 555 My problem is, how do i add the same values i have in my documents with col2 222 and col3 333 into the same documents with col2 444 and col3 555?Thanks! |
|
|
Robwhittaker
Yak Posting Veteran
85 Posts |
Posted - 2002-11-21 : 07:22:40
|
| Hi, I think your saying that you want the output of the table after the update to be 111 222 333 1 112 222 333 2 113 222 333 3 114 222 333 4 111 444 555 1 112 444 555 2 113 444 555 3 114 444 555 4 Here's what you need to doupdate tablename set tablename.value = (select b.value from tablename b where b.col1 = tablename.col1 and b.col2 = 222 and b.col3 = 333)where tablename.col2 = 444and tablename.col3 = 555Rob |
 |
|
|
tsqlnewbie
Starting Member
2 Posts |
Posted - 2002-11-21 : 08:48:20
|
| Rob,When i run it, i got this error message:Server: Msg 512, Level 16, State 1, Line 1Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.The statement has been terminated.Thanks again.. |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-11-21 : 08:56:30
|
| Check your table data and see if there are any duplicate col1's forand col2 = 222 and col3 = 333 If so then you need ot decide which one to use for the update.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|
|
|