Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7972919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:58:34+00:00 2026-06-04T07:58:34+00:00

I am having trouble writing a stored procedure that first checks a hashed password

  • 0

I am having trouble writing a stored procedure that first checks a hashed password against a user supplied password (also hashed). If the passwords match the procedure would change the password to a new password that is supplied by the user to be hashed before being stored. I took a stab at it and turned up with the code below that seems to be completely outside of proper syntax. Any help that can be supplied would be much appreciated. The code in question is below:

Create Proc UserChangePassword
    @pGuid varchar(50),
    @pOldPassword varchar(100),
    @pHashedPassword varchar (100),
    @pNewPassword varchar(10)
AS
        set @pHashedPassword = HASHBYTES('md5', @pOldPassword)
        set @pOldPassword as select st01Password from st01UserData where @pGuid = st01GUID
        If  ( @pOldPassword = @pHashedPassword)
    Begin
        Update st01UserData (
        set st01Password = HASHBYTES('md5', @pNewPassword))
        where st01GUID = @pGuid
        Return 'SUCCESS'
    Else
        RETURN 'FAILED'
GO
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:58:35+00:00Added an answer on June 4, 2026 at 7:58 am

    Some reasons behind your problems:

    • Why is your app providing @pHashedPassword if you just blindly set it to something as the first line of your procedure?
    • The syntax set @variable AS SELECT ... is not valid T-SQL syntax.
    • Your BEGIN doesn’t have a matching END.
    • The syntax UPDATE table ( is also not valid.
    • I see little reason to pull the old password into a variable, compare it outside of the query, then perform an update, when you can do all of that in one step.
    • You can’t RETURN a string, only an INT.
    • Also curious that the old password can be 100 characters, but the new password only 10?

    Try this version:

    CREATE PROCEDURE dbo.UserChangePassword
      @pGuid        VARCHAR(50),
      @pOldPassword VARCHAR(100),
      @pNewPassword VARCHAR(10)
    AS
    BEGIN
      SET NOCOUNT ON;
    
      UPDATE dbo.st01UserData
        SET st01Password = HASHBYTES('md5', @pNewPassword)
        WHERE st01Guid = @pGuid
        AND st01Password = HASHBYTES('md5', @pOldPassword);
    
      IF @@ROWCOUNT = 0
        RETURN -1;
    
      RETURN 0;
    END
    GO 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having some trouble with writing a unit test that checks my custom
So I'm writing a stored procedure and am having trouble getting the next value
I am having trouble writing query so that I can query the content of
I am having trouble writing C++ code that uses a header file designed for
I am having trouble writing a query on a mysql table of user activity
I'm having trouble writing an XPath expression to select nodes that contain certain elements,
I am writing a stored procedure to perform a dynamic search that spans 10+
I'm having trouble writing a regular expression (suitable for PHP's preg_match()) that will parse
Writing a stored procedure that will have multiple input parameters. The parameters may not
I'm having trouble writing this Query. I have 2 tables, vote_table and click_table. in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.