You are here: Re: Update n rows « MsSQL Server « IT news, forums, messages
Re: Update n rows

Posted by David Portas on 03/22/06 17:07

Khan wrote:
> Hi,
>
> I'm using table it has 100 rows, how can i update 10 or 15 rows at the
> same time with single query. In real case, if user enters "5" in
> textbox it means that the "5" rows will be updated.
>
> In SAS i was using 'outobs' {outobs = n} which means n rows will be
> affected.
>
> Thanx.


That doesn't make much sense as you have described it. Exactly which N
rows should be updated? If you don't care which then I'd say the table
design was questionable - I mean if all rows are equal then why do you
need 100 of them? If you actually do care which rows get updated then
the answer is "use a WHERE clause". Example:

UPDATE your_table
SET col1 = 'something'
WHERE col2 BETWEEN 1 AND 5 ;

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация