Update more columns in MS SQL Using a SELECT - 08-17-2004 , 05:27 AM
How can I do this in MS SQLserver (7.0 or 2000)
SET (t1.v1, t1.v2) = ((SELECT t2.v1, t2.v1
WHERE t1.key= t2.key))
WHERE (t1.v3 LIKE '%')
Re: Update more columns in MS SQL Using a SELECT - 08-17-2004 , 02:01 PM
ROW()= ..." clause, so you do one column at a time.
SET T1.v1 = (SELECT T2.v1
WHERE T1.key = T2.key),
T1.v2 = (SELECT T2.v2
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.
Re: Update more columns in MS SQL Using a SELECT - 08-25-2004 , 09:58 PM
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
SET v1 = t2.v1,
v2 = t2.v2
WHERE t2.key = t1.key
AND t1.v3 LIKE '%' ;