achievements_project/sql/CreateUserSP.sql

19 lines
804 B
MySQL
Raw Normal View History

2021-02-04 15:56:33 +00:00
<EFBFBD><EFBFBD>CREATE PROCEDURE [dbo].[CreateUser] (
@email varchar(254),
@username varchar(32),
@password char(256)
) AS
BEGIN TRANSACTION
IF EXISTS (SELECT Email FROM [User] WHERE Email = @email)
BEGIN
RAISERROR ('Email is already registered with an account.', 14, 1)
ROLLBACK TRANSACTION
RETURN 1
END
INSERT INTO [User] VALUES (@email, @username, @password)
COMMIT TRANSACTION
RETURN 0