[英]How do i update columns of two tables?
I have the following structure for Sales
and Invoices
tables 我的Sales
和Invoices
表具有以下结构
Sales 销售
SaleNo int PK
SaleDt Datetime PK
Qnty
UP
Invoices 发票
InvoiceNo int PK
InvoiceDT Datetime PK
SaleNo int PK FK
SaleDT datetime PK FK
I want to update the SaleDT of the two table and I need to set it to value '2013-01-31 08:25:38.217'. 我想更新两个表的SaleDT,需要将其设置为值'2013-01-31 08:25:38.217'。 How do I do this? 我该怎么做呢?
try this.. 尝试这个..
-- First update value in one table, then in other -首先在一个表中更新值,然后在另一个表中
UPDATE S
SET S.SaleDT = 'your value'
FROM SALE S
INNER JOIN INVOICE I
ON S.SaleNO = I.SaleNo
UPDATE I
SET I.SaleDT = 'your value'
FROM SALE S
INNER JOIN INVOICE I
ON S.SaleNO = I.SaleNo
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.