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 |
|
mary_itohan
Posting Yak Master
191 Posts |
Posted - 2008-10-09 : 11:25:50
|
Hello,I have a table that could contain a few duplicate columns.Whats the best way to update a column and set the value of only "ONE" row to an update statusie update history set Sent_Route = @each_recipient where batch = @transactionid and Receipient = @final_recipient bear in mind the column receipient above could have duplicate values in a transaction.Do i first do a select to get the top 1, PK value before the update or do i use @@rowcount to check to make sure only one value is updated ???_____________________Yes O ! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-09 : 12:03:01
|
| you can just useupdate top 1 history set Sent_Route = @each_recipient where batch = @transactionid and Receipient = @final_recipient |
 |
|
|
mary_itohan
Posting Yak Master
191 Posts |
Posted - 2008-10-09 : 13:22:31
|
| No sir, Msg 102, Level 15, State 1, Procedure S_billing, Line 435Incorrect syntax near '1'._____________________Yes O ! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-09 : 13:41:01
|
quote: Originally posted by mary_itohan No sir, Msg 102, Level 15, State 1, Procedure S_billing, Line 435Incorrect syntax near '1'._____________________Yes O !
just missed a bracesupdate top (1) history set Sent_Route = @each_recipient where batch = @transactionid and Receipient = @final_recipient |
 |
|
|
mary_itohan
Posting Yak Master
191 Posts |
Posted - 2008-10-09 : 13:56:23
|
| tnx_____________________Yes O ! |
 |
|
|
|
|
|