dbTalk Databases Forums  

RE: when calling UPDATE from the result set of a SELECT statement, is

microsoft.public.sqlserver.clustering microsoft.public.sqlserver.clustering


Discuss RE: when calling UPDATE from the result set of a SELECT statement, is in the microsoft.public.sqlserver.clustering forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Linchi Shea
 
Posts: n/a

Default RE: when calling UPDATE from the result set of a SELECT statement, is - 12-01-2007 , 09:25 AM






Most likely, you'll get the first value (BTW, remove the OREDER BY clause).
But that is not guaranteed at all. BOL explicitly documents this scenario as
undefined/nondeterministic:

"The results of an UPDATE statement are undefined if the statement includes
a FROM clause that is not specified in such a way that only one value is
available for each column occurrence that is updated, that is if the UPDATE
statement is not deterministic."

For an example of UPDATE nondeterminism at work, see
http://sqlblog.com/blogs/linchi_shea...ic-update.aspx

Linchi

"DR" wrote:

Quote:
when calling UPDATE from the result set of a SELECT statement, is the order
in which rows from the SELECT statement 100% geronteed?

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?




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.