Nim*_*sad 0 sql sql-server sql-server-2008
基本上当我注册(注册详细信息转到登录表)时,此数据将转到2个表:
使用@Attrib我检查哪些数据需要转到哪个表.但是我在第一else部分附近遇到错误.
错误是:
期待SELECT或''(''的'@Attrib'附近的语法不正确
这是代码:
ALTER procedure [dbo].[Registration_SP]
(
@Email varchar(50),
@Password varchar(50),
@Repassword varchar(50),
@Attrib varchar(50)
)
AS
BEGIN
Insert into Login (Email,Password,Repassword,Attrib)
values(@Email,@Password,@Repassword,@Attrib)
IF (@Attrib = 'Student')
BEGIN
Insert into StudentReg
(StudentId,FirstName,LastName,Gender,Address1,Address2,Address3,
LandPhone,MobilePhone,Budget,IsFinancialSupport,CourseName,
IsJobSeeker,Country,Region,IsSupportActive,RegDate,ImagePath,
ShortCode)
Values(@Email,'','','','','','','','','','','','','','','','','','')
END
ELSE (@Attrib = 'Financial Supporter')
BEGIN
Insert into SupporterReg
(SupporterId,SupporterName,University,ContactNo,StudentLocation,RegDate,
ImagePath,ShortCode)
Values(@Email,'','','','','','','')
END
Run Code Online (Sandbox Code Playgroud)
进一步澄清,我已经附上了下图:

之后你ELSE失踪IF了:
即
ELSE (@Attrib = 'Financial Supporter')
Run Code Online (Sandbox Code Playgroud)
应该
ELSE IF (@Attrib = 'Financial Supporter')
Run Code Online (Sandbox Code Playgroud)
的ELSE情况下,有没有条件,所以报出语法错误.
-- Should be no condition here, syntax error.
ELSE (@Attrib = 'Financial Supporter')
Run Code Online (Sandbox Code Playgroud)
我假设你打算这样做 ELSE IF
ELSE
IF (@Attrib = 'Financial Supporter')
Run Code Online (Sandbox Code Playgroud)