If you check Books Online or other references, you'll find that you can't do this in SQL Server CE.
- No FROM clause
- No correlated sub-queries
Basically, the only data an UPDATE statement can reference is the data in the row being updated.
There are only two methods that I have found to get around this:
1. Client app runs a select, then fire off one or more direct updates
2. INSERT the new values, then DELETE the old values
The first is pretty much how CE is (as far as I know) intended to work. There is no T-SQL, for example, so IF blocks and other procedural logic needs to be embedded in the application, not the SQL.
The second mimic what an UPDATE looks like in a trigger; A delete and an insert. And provided you re-structure your data to make this possible, it's quite effective.
Neither are 'great', but then CE really is meant to be the "least you can get away with". It's almost like it's more a slightly flashy persistance engine (save stuff to disk in a funk flexible format), and less a real database engine.
Once you get used to it's limitations, and the ways to work around them, however, it can be pretty useful. For specific tasks.
UPDATE
, what is the error message for the first version? – PropyliteWe can still do clever things with it, can You???
– Fabri