I am trying to make a stored proc and SQL keeps telling me there is "Incorrect syntac near 'END'" on line 47, which is the last line of code. I do not see anything wrong, can I get second set of eyes please? Thanks
CREATE PROC spMemberInfo
@UpdateType AS char(6) = NULL,
@UserName AS varchar(256) = NULL,
@Email AS varchar(255) = NULL,
@WebSite AS varchar(255) = NULL,
@ContactList AS char(1) = NULL,
@IsStaff AS bit = NULL
AS
SET NOCOUNT ON;
SET XACT_ABORT ON;
DECLARE @ErrorNum int;
BEGIN TRANSACTION
--Process a new registration attempt
IF (@UpdateType = 'Insert')
BEGIN
--Check to see if the member is already registered
IF NOT EXISTS (SELECT TOP 1 1 FROM dbo.MemberInfo WITH (NOLOCK) WHERE UserName = @UserName)
BEGIN
INSERT INTO dbo.MemberInfo (UserName, Email, WebSite, ContactList, IsStaff)
VALUES (@UserName, @Email, @WebSite, @ContactList, @IsStaff);
SELECT @ErrorNum = @@ERROR;
END
ELSE
--Process a profile update
BEGIN
UPDATE dbo.MemberInfo
SET Email = @Email,
WebSite = @WebSite,
ContactList = @ContactList,
IsStaff = @IsStaff
WHERE UserName = @UserName;
END
--Check for errors and commit if none
IF (@ErrorNum = 0)
BEGIN
COMMIT
END
ELSE
BEGIN
ROLLBACK
END
--
If I get used to envying others...
Those things about my self I pride will slowly fade away.
-Stellvia