Updating field from one table to another sql single girl dating delhi

17 Apr

Specifies the temporary named result set or view, also known as common table expression (CTE), defined within the scope of the UPDATE statement.The CTE result set is derived from a simple query and is referenced by UPDATE statement.

Table Structures and values: Table A has four columns: a, b, c, d (a is the primary key column) Table B has five columns: a1, b1, c1, d1, e1 (a1 and b1 together constitute the primary key for this table) The foreign key relationship between the two tables is based on A.a = B.a1 The data in these 2 tables is as follows: I. Table B a1 b1 c1 d1 e1 1 x1 y1 z1 40 2 a1 b1 c1 50 The requirement is to write a SQL to update columns b, c and d in Table A from the columns b1, c1 and d1 from Table B where-ever the join condition satisfies and e1 40) / Results after the update: a b c d ———————————— 1 x y z 2 a1 b1 c1 3 t x z SQL Server: UPDATE TABLEA SET b = TABLEB.b1, c = TABLEB.c1, d = TABLEB.d1 FROM TABLEA, TABLEB WHERE TABLEA.a = TABLEB.a1 AND TABLEB.e1 40 GO Note: This is an extension in SQL Server i.e.

Visit the ITKnowledge Exchange and get answers to your developing questions fast.

CLAIM) ================================== MORE INFORMATION ON THIS TOPIC ================================== The Best Web Links: tips, tutorials and more.

If this is something you need to do all the time, I would suggest something else, but for a one-off or very small tables it should be sufficient.

You could create a trigger on table B that updates table A every time field_2 on table B is updated.