achievements_project/sql/CreateUserSP.sql

19 lines
896 B
Transact-SQL
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

CREATE PROCEDURE [dbo].[CreateUser] (
@email varchar(254),
@username varchar(32),
@salt char(32),
@password char(64)
) AS
BEGIN TRANSACTION
IF EXISTS (SELECT Email FROM [User] WHERE Email = @email)
BEGIN
PRINT 'Email is already registered with an account.'
ROLLBACK TRANSACTION
RETURN 1
END
INSERT INTO [User](Email, Username, Salt, [Password]) VALUES (@email, @username, @salt, @password)
COMMIT TRANSACTION
RETURN 0