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 |
|
cplusplus
Aged Yak Warrior
567 Posts |
Posted - 2011-08-22 : 15:54:05
|
| How can i run teh following update, all i want is to update the value just to first row of the tablecan i do :update top 1 @myTemptable set actualCost=@Actualcosti have many rows within mytemptable, just want to update the value to first row.thank you for the helpful info. |
|
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2011-08-22 : 16:01:55
|
define first row, what makes it first date , an id or what? but something like this might work. always testwith cte(ActualCost, ProductUID)As(SELECT TOP 1FROM ActualCost, ProductUIDORDER BY ProductUID ASC)UPDATE tgt SET tgt.actualCost=@Actualcost FROM ActualCost tgtinner join srcon tgt.ProductUID = src.ProductUID If you don't have the passion to help people, you have no passion |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-08-22 : 23:45:07
|
| even update top (1) should work------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2011-08-23 : 02:29:14
|
"even update top (1) should work"which reminds me!You could do:SET ROWCOUNT 1UPDATE ...SET ROWCOUNT 0 to restrict the Update command to a single row - make sure you set ROWCOUNT back to zero though - otherwise all following commands will process only one row too! |
 |
|
|
cplusplus
Aged Yak Warrior
567 Posts |
Posted - 2011-08-23 : 10:35:11
|
| Visakh, Thank you very much. It worked good. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-08-23 : 11:28:54
|
| welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|