Monday, March 12, 2012

Multiple table update

Hi There

I am using tsql in Sql Server 2005.

Is it possible/how do i update multiple tables in a single update statement.

I want to do something like this.

UPDATE A, B, C, D SET A.Col1 = ?, B.Col2 = ?, C.Col3 = ?, D.Col4 = ?

FROM TableA AS A

JOIN TABLEB AS B ON B.ID = A.ID

JOIN TABLEC AS C ON C.ID = A.ID

JOIN TABLED AS D ON D.ID = A.ID

Basically all the tables are related, i want to update values in all the tables in a single update but i just cannot seem to get the syntax correct, BOL also has no example of multiple table update so i am not even sure if this is possible.

Thanx

you can not update multiple tables in single update statement . what u can do is put all these different update statement in a begin tran/commit tran

Madhu

No comments:

Post a Comment