Here, we will see how to change the password visually and programmatically in SQL Server 2012. This is a common problem which is frequently asked in many sites. Many people forget their password shortly after installing Microsoft SQL Server or they have not used SQL Server after a long time. You can change the password and once again access your account using Windows Authentication mode. So let's have a look at a practical example. The example is developed in SQL Server 2012 using the SQL Server Management Studio.
To Change Password Visually
To change the SQL Server password for the sa login just do the following.
Open SQL Server 2012, and select the authentication mode and Login using Windows Authentication.
Now click on the connect Button and you will be taken to the SQL Server Management Studio.
In SQL Server Management Studio, Press F8 to open the Object Browser in SQL Server Management Studio and expand it. Object Explorer -> Security -> Login -> select sa
Now right-click on the sa and select property.
Now click on the property and the login property window will be opened.
Now change the password and confirm it. Press OK Button.
To Change Password Programmatically
- Open the SQL Server Management Studio.
- Click new query to open a New Query.
- Paste and execute the following code.
USE [master]
GO
ALTER LOGIN [sa] WITH PASSWORD=N'New Password', DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
GO
Now Press F5 to execute the query.