UPDATE附近的语法不正确,在创建存储过程时会出现外部错误

时间:2014-06-18 09:09:36

标签: sql-server tsql

IF OBJECT_ID('*[dbo].[UpdateData]*', 'U') IS NULL
BEGIN    

CREATE PROC [dbo].[UpdateData]   
AS    
UPDATE [DB1].[dbo].[Staff]
SET
[Name1]= 'Value1',
[Name2]= 'N2',
[Name3]= 'N3'
FROM [DB1].[dbo].[Staff] s
LEFT OUTER JOIN [DB1].[dbo].[Table1] si on s.[ID]=si.[ID]

 RETURN;       
END    

有没有人知道为什么上面的代码片段会在UPDATE附近生成"不正确的语法,期望外部"在UPDATE [DB1].[dbo].[Staff]

下面一行的UPDATE关键字处

1 个答案:

答案 0 :(得分:-1)

像这样更改更新查询

UPDATE [DB1].[dbo].[Staff]
SET
[Name1]= s.[BPNumber],
[Name2]= 'N2',
[Name3]= 'N3'
FROM [DB1].[dbo].[Staff] s
LEFT OUTER JOIN [DB1].[dbo].[Table1] si on s.[ID]=si.[ID]