我正在尝试将表1的日期列更新为将来的日期,否则称为退役。我在FROM语句下遇到语法错误。除了
之外,我没有其他任何信息在'FROM'附近不正确的语法。
UPDATE [database1].[dbo].[table1]
SET [database1].[dbo].[table1].[datecolumn1] = '9999-12-31 00:00:00.000'
WHERE [database1].[dbo].[table1].[END_DATE] > GETDATE()
FROM [database1].[dbo].[table1]
INNER JOIN [database2].[dbo].[table2] ON [database1].[dbo].[table1].[namecolumn1] = [database2].[dbo].[table2].[namecolumn2]
GO
答案 0 :(得分:3)
您的WHERE
条款应该在FROM
之后:
UPDATE [database1].[dbo].[table1]
SET [database1].[dbo].[table1].[datecolumn1] = '9999-12-31 00:00:00.000'
FROM [database1].[dbo].[table1]
INNER JOIN [database2].[dbo].[table2] ON [database1].[dbo].[table1].[namecolumn1]=[database2].[dbo].[table2].[namecolumn2]
WHERE [database1].[dbo].[table1].[END_DATE] > GETDATE()
GO
答案 1 :(得分:2)
where
子句应该是最后一个。此外,你有一个拼写错误的单词" innner" (应该是"内部" - 或者更好,完全放弃它):
UPDATE [database1].[dbo].[table1]
SET [database1].[dbo].[table1].[datecolumn1] = '9999-12-31 00:00:00.000'
FROM [database1].[dbo].[table1]
JOIN [database2].[dbo].[table2] ON
[database1].[dbo].[table1].[namecolumn1] =
[database2].[dbo].[table2].[namecolumn2]
WHERE [database1].[dbo].[table1].[END_DATE] > GETDATE()