achievements_project/sql/CreateUserSP.sql

20 lines
896 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),
2021-02-05 09:59:17 +00:00
@salt char(32),
@password char(64)
2021-02-04 15:56:33 +00:00
) AS
BEGIN TRANSACTION
IF EXISTS (SELECT Email FROM [User] WHERE Email = @email)
BEGIN
2021-02-05 09:59:17 +00:00
PRINT 'Email is already registered with an account.'
2021-02-04 15:56:33 +00:00
ROLLBACK TRANSACTION
RETURN 1
END
2021-02-05 09:59:17 +00:00
INSERT INTO [User](Email, Username, Salt, [Password]) VALUES (@email, @username, @salt, @password)
2021-02-04 15:56:33 +00:00
COMMIT TRANSACTION
RETURN 0