achievements_project/sql/CreateUserSP.sql

22 lines
976 B
MySQL
Raw Normal View History

2021-02-04 15:56:33 +00:00
<EFBFBD><EFBFBD>CREATE PROCEDURE [dbo].[CreateUser] (
2021-02-06 01:19:11 +00:00
@email VARCHAR(254),
@username VARCHAR(32),
@salt CHAR(32),
@password CHAR(64),
@ID INT OUTPUT
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-06 01:19:11 +00:00
SET @ID = @@IDENTITY
2021-02-04 15:56:33 +00:00
COMMIT TRANSACTION
RETURN 0