title: Return value based on count from SQL Server Stored Procedure
body: <p>I have the following SQL Server Stored Procedure which validates a password.</p>
  
  <pre><code>ALTER PROC [dbo].[spValidatePassword]
  @UserId uniqueidentifier,
  @Password NVARCHAR(255)
  AS
  BEGIN
  
  DECLARE @PasswordHash NVARCHAR(255) = HASHBYTES('SHA2_512', (SELECT @Password + CAST((SELECT p.PasswordSalt FROM Passwords p WHERE p.UserId =     @UserId) AS NVARCHAR(255))))
  
  SELECT COUNT(*)
  from Passwords
  WHERE UserId = @UserId
  AND [Password] = @PasswordHash
  
  
  --return 1 if valid password
  --return 0 if not valid
  
  END
  </code></pre>
  
  <p>How can I return 1 from the stored procedure if the count is greater than zero, and zero otherwise?</p>