﻿CREATE PROCEDURE [dbo].[USR_UserNameExists]
	@UserName VARCHAR(255),
	@UserId BIGINT
	
AS
DECLARE @Result BIT;

SELECT @Result = CASE WHEN EXISTS(SELECT 1 FROM Users WHERE UserName = @UserName AND ISNULL(@UserId, UserId) <> UserId) THEN 1 ELSE 0 END
RETURN @Result
