Click here to Skip to main content
14,971,029 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Update two table using same time

EX:

update tabl1 , tbl2 set tabl1.filed='' , tbl2.field=''.
Posted
Comments
Maciej Los 12-Apr-13 2:11am
   
Does these tables are related? Please, provide more details.

1 solution

Hi,

Its not possible. You can only update one table in update statement.

For the above scenario use sp like below

SQL
BEGIN TRANSACTION

UPDATE Table1
  SET Table1.ColunmName = 'XXX' 
WHERE Condition

UPDATE Table2
SET Table2.ColunmName = 'XXX' 
WHERE Condition

COMMIT 

Click Here[^] for more details about transaction.
   
v3
Comments
Shanalal Kasim 12-Apr-13 1:55am
   
Please vote

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900