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 |
|
MageshkumarM
Yak Posting Veteran
61 Posts |
Posted - 2011-03-15 : 09:31:16
|
Hi,I need a small statement to UPDATE first 3 rows.. without where case.I have table A in that i had 300 rows.. i want to update first 3 rows..can any one help me out of this..Thnk in advanceMAG,Start with the new Idea.. http://mageshkumarm.blogspot.com/ |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-03-15 : 09:58:59
|
| Why don't you want to use WHERE or CASE? If you don't want to use the tools SQL provides you, the best way is to jsut open the table in SSMS and manually update the first 3 rows you see.JimEveryday I learn something that somebody else already knew |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-03-15 : 10:12:04
|
quote: Originally posted by MageshkumarM Hi,I need a small statement to UPDATE first 3 rows.. without where case.I have table A in that i had 300 rows.. i want to update first 3 rows..can any one help me out of this..Thnk in advanceMAG,Start with the new Idea.. http://mageshkumarm.blogspot.com/
Why do you want not to use where clause?update top (3) from table set col='somevalue'MadhivananFailing to plan is Planning to fail |
 |
|
|
sqldataguy
Starting Member
12 Posts |
Posted - 2011-03-15 : 11:00:01
|
| I also wonder why you don't want to use WHERE or CASE, but taking your word for it.... Copy the primary key of the rows you want to update to a temp table, then inner join the initial table with the temp table in the UPDATE statement so it will only update those three rows |
 |
|
|
jcelko
Esteemed SQL Purist
547 Posts |
Posted - 2011-03-15 : 23:29:05
|
quote: Originally posted by MageshkumarM I need a small statement to UPDATE first 3 rows.. without where case.I have table A in that I had 300 rows.. I want to update first 3 rows..
Tables have no ordering by definition so this makes no sense. Please post real DDL. Learn to use ISO-11179 rules for the data element names, avoid needless dialect and use ISO-8601 temporal formats, codes and so forth. People cannot read your mind, so post your code and clear specs if you really want help. --CELKO--Books in Celko Series for Morgan-Kaufmann PublishingAnalytics and OLAP in SQLData and Databases: Concepts in Practice Data, Measurements and Standards in SQLSQL for SmartiesSQL Programming Style SQL Puzzles and Answers Thinking in SetsTrees and Hierarchies in SQL |
 |
|
|
|
|
|