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 |
|
bobz_0585
Yak Posting Veteran
55 Posts |
Posted - 2009-05-02 : 09:53:58
|
hello all ,i have this seemingly simple yet i couldnt find a way to do that..i want to update the top x columns of a table but since i cannot use update top @variable so i edited the row count now i need the order of the table to be desc order ...i tried inline query but i kept getting an error..thanks in advance for youre help |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-05-02 : 18:02:48
|
Please show us table structure and give sample data and wanted result.Webfred No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
bobz_0585
Yak Posting Veteran
55 Posts |
Posted - 2009-05-03 : 04:19:48
|
sorry for the late reply i forgot to subscribe for the post....i have a table that i import new columns to by copying from a remote table...i want to edit the rows that were just entered...all together...i wanted to updated the top @dif variable...which contains the amount of record just added but i couldnt so i thought about setting the row count =@dif variable.. in the table i corp data into there is a identity column called id so the newer columns have a hiegher id value...i wanted to order the table in desc order and edit the top @var but it is impossible... |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-05-03 : 07:50:21
|
Do you mean this?update t1set column='what_you_want'from table t1join(select top @dif [id] from table order by [id] desc)t2on t1.id=t2.id Webfred No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
bobz_0585
Yak Posting Veteran
55 Posts |
Posted - 2009-05-04 : 04:15:44
|
| thanks man it worked like a charm..although the top @dif ..so i changed the rowcount to be equal to @dif and it worked thank you webfred |
 |
|
|
|
|
|