How can I do this in MS SQLserver (7.0 or 2000)
Update t1
SET (t1.v1, t1.v2) = ((SELECT t2.v1, t2.v1
FROM t2
WHERE t1.key= t2.key))
WHERE (t1.v3 LIKE '%')
--CELKO-- - 17 Aug 2004 20:01 GMT
>> How can I do this in MS SQLserver (7.0 or 2000) <<
Unfortunately, SQL Server does not have the SQL-92 syntax for a "SET
ROW()= ..." clause, so you do one column at a time.
UPDATE T1
SET T1.v1 = (SELECT T2.v1
FROM T2
WHERE T1.key = T2.key),
T1.v2 = (SELECT T2.v2
FROM T2
WHERE T1.key = T2.key)
WHERE T1.v3 LIKE '%'; -- strange predicate?
They have a version of the UPDATE.. FROM.. that appeared in Sybase and
other products. Unfortunately, it is unpredictable, does not port and
does not match the semantivcs of other products with the same syntax.
Anith Sen - 26 Aug 2004 03:58 GMT
MS SQL Server supports a proprietary syntax for its UPDATE statement which
uses a FROM clause similiar to that in a SELECT statement. Thus you could
do:
UPDATE t1
SET v1 = t2.v1,
v2 = t2.v2
FROM t2
WHERE t2.key = t1.key
AND t1.v3 LIKE '%' ;

Signature
Anith