Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
TSQL 2000/2005 Query Conundrum
Message
 
 
To
10/12/2007 13:22:09
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01274411
Message ID:
01274497
Views:
11
Too late, I've read it already :) Why not using an INNER JOIN for Update ?

E.g. UPDATE x SET myField = 'FANC' from table1 x inner join (complex select) y on x.ID = y.ID

>Nevermind, I got it working right :o)
>
>
>Can a field in the result set be updated based on the query result? In other words (I'm trying this unsuccessfully):
>
>UPDATE table1 x SET myfield = 'FANC'
>  WHERE EXISTS
>  (SELECT i.* from table1 i
>  WHERE (i.field1 = 'FA' and field2 IN('AAA','BBB') AND i.field3 = 0)
>     AND NOT EXISTS (SELECT * from table3 a WHERE a.table2id = i.table2id AND a.field4 = i.field4))
>     AND (EXISTS (SELECT * from table2 s WHERE s.table2id = i.table2id AND s.fielda <> 'X'
>                   AND s.fieldb <> 'I')
>     OR NOT EXISTS (SELECT * from table2 s WHERE s.table2id = i.table2id)) and x.field4=i.field4)
>
>
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform