我正在尝试在 sql server 中编写一个相当简单的存储过程。如果我的错误的来源很明显,我没有抓住它。SSMS 给我“')' 附近的语法错误。” 任何帮助,将不胜感激。这是程序:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sprocAddSymbols] @symbol NVARCHAR(10)
AS
BEGIN
DECLARE @symbolCheck NVARCHAR(10)
DECLARE @statusCheck NVARCHAR(10)
SET @symbolCheck = (SELECT Symbol FROM tblSymbolsMain WHERE Symbol = @symbol)
SET @statusCheck = (SELECT SymbolStatus FROM tblSymbolsMain WHERE Symbol = @symbol)
IF (@symbolCheck IS NOT NULL AND @statusCheck = 'Inactive')
BEGIN
UPDATE tblSymbolsMain
SET SymbolStatus = 'Active'
WHERE Symbol = @symbol
END
ELSE
INSERT INTO tblSymbolsMain (Symbol, DateAdded, Status)
VALUES (@symbol, GETDATE(), 'Active')