CodeSnip:Change Password for a SQL Server User
page 1 of 1
Published: 01 Dec 2004
Unedited - Community Contributed
Abstract
Most security experts' recommendations include changing passwords frequently to enhance security. It is easy to change the password on a SQL Server Username via Query Analyzer. Changing the password with Query Analyzer makes it easy to coordinate changing the password on the database server at the same time as it is changed in the connection string. This approach provides the flexibility to change the password at the most appropriate time for the application.
by Web Team at ORCS Web
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 8409/ 17

Most security experts' recommendations include changing passwords frequently to enhance security. It is easy to change the password on a SQL Server Username via Query Analyzer. Changing the password with Query Analyzer makes it easy to coordinate changing the password on the database server at the same time as it is changed in the connection string. This approach provides the flexibility to change the password at the most appropriate time for the application.

To change the SQL Server Username password, just connect to the database with Query Analyzer using the SQL Server Username that is being updated and the current password. Then run "sp_password" to change the password.

sp_password [ [ @old = ] 'old_password' , ]
      { [ @new =] 'new_password' }
      [ , [ @loginame = ] 'login' ]

The Office Microsoft Documentation for sp_password

Here is a simple example that changes the current password from
"currentPSWD" to "newPSWD";

sp_password 'currentPSWD', 'newPSWD'

Be sure to use a strong password, "newPSWD" is just an example. I always like to test any change like this right away. For a quick test to confirm that the new password is working, close Query Analyzer and then re-connect with the new password. That is all there is to it, except for changing your connections string. It is obvious, but still critical to remember to change the password in your connection string if this SQL Username is used in your code. Once the password has been changed and tested with Query Analyzer, update the connection string with the new password and test that everything still works correctly, and you're done.

By David Weber, a support specialist with ORCS Web, Inc. - a company that provides managed hosting services for clients who develop and deploy their applications on Microsoft Windows platforms.



User Comments

Title: feedback   
Name: JB
Date: 2011-02-21 11:49:29 PM
Comment:
Thanks for the article. However most times people will be wanting to reset a password, is when it is lost or forgotten. The above doesnt help during that situation.
Title: Change SQL password   
Name: yitiana
Date: 2010-08-04 4:47:48 AM
Comment:
I know a MS SQL Server password reset tool which can instantly reset MS SQL Server and Express 2000/2005/2008 password, including SA and other users password, no matter the password is how long and complex, Only the master.mdf file is needed for resetting the password within seconds. And you do not need to reinstall MS SQL Server on your PC. Save more time and trouble.

MS SQL Server password recovery: http://www.passwordunlocker.com/sql-server-password-recovery.html
Title: changing MSSQL password   
Name: sam
Date: 2009-05-27 5:21:38 AM
Comment:
thx for your article.Kindly send me exact coding lines for password change in MSSQL 2000.
Also tell me, can this coding lines will be useful for changing password for DB schema owner?
Mailme at sampadah@hotmail.com Pls mail me ASAP.Its very urgent.
Title: changing MS SQL Password   
Name: Kaushal Prasad
Date: 2008-10-29 1:43:27 AM
Comment:
I WANT TO KNOW EXACT CODDING TO CHANGE MY OLD PASSWORD ' kaushal123 ' TO NEW PASSWORD ' KP456 '. YOU MAY MAIL ME ON kaushalprasad26@gmail.com
Title: CHANGING MS SQL PASSWARD   
Name: KUNAL SHAH
Date: 2007-01-06 12:59:19 AM
Comment:
I AM HAPPY TO SEE YOUR ARTICLE ON WEB BY GOOGLE SEARCH. I WANT TO KNOW EXACT CODDING TO CHANGE MY OLD PW ' 12345 ' TO NEW PW ' ABCDE '. YOU MAY MAIL ME ON kunals1999@yahoo.com






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-24 3:48:47 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search