-1

Somethings like:

UPDATE Table(Customers or Customers2) SET City ="A"
FROM (
SELECT City FROM Customers where id=1
UNION
SELECT City FROM Customers2 where id=1)
Claire
  • 3,146
  • 6
  • 22
  • 37
  • Somethings like: UPDATE Table(Customers or Customers2) SET City ="A" FROM ( SELECT City FROM Customers where id=1 UNION SELECT City FROM Customers2 where id=1) – Sergio Langa Jul 29 '19 at 18:41
  • I recommend that you read this article and try posting your question again. https://spaghettidba.com/2015/04/24/how-to-post-a-t-sql-question-on-a-public-forum/ – Tab Alleman Jul 29 '19 at 18:42
  • you can't update a table or anothers table .. – ScaisEdge Jul 29 '19 at 18:43
  • You need to run this with 2 different update statements. `UPDATE t SET City = 'A' FROM table1 AS t WHERE id = 1` and then `UPDATE t SET City = 'A' FROM table2 AS t WHERE id = 1` – JoeFletch Jul 29 '19 at 18:46
  • Thanks you so much. – Sergio Langa Aug 05 '19 at 12:21

1 Answers1

0

SQL Server can only update one table at a time in a given UPDATE statement. You need to use two updates:

UPDATE Customers 
    SET City = 'A'
    WHERE id = 1;

UPDATE Customers2 
    SET City = 'A'
    WHERE id = 1;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786