你好程序员我正在编写一个 TSQL 内联表函数,实际上我在 sql 中不够好,当我完成我的代码时,我得到了这个错误“'BEGIN'附近的语法不正确。” ,谁知道解决方法,请给我。顺便说一句,当我双击错误消息时,它选择了最后一个“结束”
create FUNCTION [dbo].[CheckLogin]
(
@un varchar(max),
@pw varchar(max)
)
RETURNS TABLE
AS
begin
declare @unexist int, @unpwmatch int, @uid bigint
declare @uisactivated bit , @uisdeleted bit
-----
set @unexist = (select COUNT(UserAccessInfo.UserId) FROM UsersAccessInfo
WHERE UserAccessInfo.UserName = @un OR UserAccessInfo.UserEmail = @un)
------
set @unpwmatch = (select count(usersaccessinfo.userid) from usersaccesinfo
WHERE (usersaccessinfo.UserName = @un) AND (usersaccessinfo.UserPassword = @pw) OR
(usersaccessinfo.UserEmail = @un) AND (usersaccessinfo.UserPassword = @pw))
------
set @uid =(select usersaccessinfo.userid from usersaccessinfo where
serAccessInfo.UserName = @un OR UserAccessInfo.UserEmail = @un)
------
if @uid <> Null
begin
set @uisactivated =(select usersaccessinfo.userisactivated from usersaccessinfo
where usersaccessinfo.userid=@uid)
end
------
if @uid <> null
begin
set @uisactivated =(select usersaccessinfo.userisactivated from usersaccessinfo
where usersaccessinfo.userid=@uid)
end
------
if @unexist = 0
begin
select dbo.getreportbyid('1004')
end;
else if @unpwmatch = 0
begin
select dbo.getreportbyid('1005')
end;
else if @uid<>0
begin
if @uisactivated =0
begin
select dbo.getreportbyid('1002')
end;
else if @uisdeleted = 1
begin
select dbo.getreportbyid('1003')
end;
end;
else
begin
select ('successful') as report
end;
return
end;