Update Multiple Tables at a Time - SQL Server/T-SQL

Posted by peace on Stack Overflow See other posts from Stack Overflow or by peace
Published on 2010-05-21T10:03:12Z Indexed on 2010/05/21 10:10 UTC
Read the original article Hit count: 231

Filed under:
|
|
|
|

I have two tables, Customer and CustomerPhone.

Single record in Customer can have multiple CustomerPhone records. As you see in the image below, Phone and Fax resides in CustomerPhone table whereas the rest of the fields resides in Customer table. If user want to edits a customer record, obviously i will have to update the record in Customer table and at least two records from CustomerPhone (Phone and Fax).

http://img714.imageshack.us/img714/9417/snapshotapp.jpg

I could write two update statements, one Update customerPhone and the second update Customer table. Is there a better solution?

© Stack Overflow or respective owner

Related posts about tsql

Related posts about sql