tableA
myid
-----------
0
1
2
3
4
5
UPDATE tableB u
SET myid = i.myid
FROM tableA i
ORDER BY myid
Will this always update tableB with 5 since it is the last one? is this 100%
garonteed to follow the order of the source result set?
UPDATE tableB
SET myid = (SELECT MAX(i.myid)
FROM tableA i)
Note that that would set the value of myid to 5 in every row of tableB,
which I assume is what you wanted. It was hard to tell exactly what you
wanted to do since the UPDATE query you gave us is not syntacally correct.
Tom
"DR" <softwareen...@yahoo.com> wrote in message
news:OIc2XN8M...@TK2MSFTNGP04.phx.gbl...
Hi DR,
Completely random - depends what is happening at the time in the way the
engine produces the query results.
What you trying to do?
As Tom answers - you can use a sub-query if you are just after the max
value.
Tony
--
Tony Rogerson, SQL Server MVP
http://sqlblogcasts.com/blogs/tonyrogerson
[Ramblings from the field from a SQL consultant]
http://sqlserverfaq.com
[UK SQL User Community]
"--CELKO--" <jcel...@earthlink.net> wrote in message
news:330376b1-338d-4294...@d61g2000hsa.googlegroups.com...
Instead of name calling, why not tell us what your mindset was that
lead you to think that this would ever be a valid statement? My
experience is that this comes from thinking that a table behaves like
a sequential file system, instead an unordered table.
You got this wrong because of some problem with your whole mindset on
RDBMS. I have to write books and teach people SQL and RDBMS, so I
need to know both the right answer (which you got from several other
posters) AND I need to know why the error happened. Mop the floor and
fix the leak!
Perhaps I mistook you for someone who was actually trying to learn
something. If you want to learn, get over it, kid. You might want to
read this:
http://www.apa.org/journals/psp/psp7761121.html
"Unskilled and Unaware of It: How Difficulties in Recognizing One's
Own Incompetence Lead to Inflated Self-Assessments"