How to change SQL Server Authentication Mode by using TSQL Query

SQL Server Authentication mode can be changed by using GUI.

Simply click on Server -> Properties -> Security.

There you can change the SQL Server Authentication mode to

1. Windows Authentication mode
2. SQL Server and Windows Authentication mode( Mixed Mode)

You can also use below scripts to check and change the SQL Server Authentication mode:

--Use this to Check the SQL Server Authentication Mode

SELECT CASE SERVERPROPERTY('IsIntegratedSecurityOnly') 
WHEN 1 THEN 'Windows Authentication' 
WHEN 0 THEN 'Windows and SQL Server Authentication' 
END as [SQLServerAuthenticationMode]
------------------------------------------------------------------------------
--To Change to Windows Authentication

USE [master]
GO
EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE',
N'Software\Microsoft\MSSQLServer\MSSQLServer', N'LoginMode', REG_DWORD, 1
GO
------------------------------------------------------------------------------
--To change to Mixed Mode( SQL Server and Windows Authentication mode)

USE [master]
GO
EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE',
N'Software\Microsoft\MSSQLServer\MSSQLServer', N'LoginMode', REG_DWORD, 2
GO

------------------------------------------------------------------------------
--Finally:
--Please note: After running one of the above query, you have to restart SQL Server and Agent Service.



Comments

  1. Very elegantly composed article. It was a magnificent article to peruse. Complete rich substance and completely useful about SQL server. Cheap Dedicated Server

    ReplyDelete
  2. I am very thankful to you that you have shared this information with us. I got some different kind of knowledge from your web page, and it is really helpful for everyone. Thanks for share it. Read more info about Online Hackathon for Beginners USA

    ReplyDelete

Post a Comment

Popular posts from this blog

AWS: Benefits of using Amazon S3

Google To Acquire Looker For $2.6 Billion

Python - GUI - Tkinter(Bar & Pie Chart)