我想对varchar字段进行更新,将其更新为另一个日期字段中的Date值(格式为MM / DD / YYYY格式)以及硬编码文本。可能是这样,其中EFFDT列是日期时间字段,DESCRIPTION是varchar字段:
UPDATE R
SET R.DESCRIPTION = 'Account Inactivated on: " + P.EFFDT
FROM dbo.ProductReviews AS R
INNER JOIN dbo.products AS P
ON R.pid = P.id
WHERE R.id = 'A0358'
结果示例为:
DESCRIPTION
Account Inactivated on 07/05/2018
这怎么实现?
答案 0 :(得分:1)
您似乎想要:
UPDATE R
SET R.DESCRIPTION = 'Account Inactivated on: ' + FORMAT(P.EFFDT, 'MM/dd/yyyy')
FROM dbo.ProductReviews R INNER JOIN
dbo.products P
ON R.pid = P.id
WHERE R.id = 'A0358';