Tuesday, September 23, 2014

Script to find Windows authentication mode/ Mixed authentication mode in SQL Server using TSQL

DECLARE @AuthenticationMode INT

EXEC master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE'
 ,N'Software\Microsoft\MSSQLServer\MSSQLServer'
 ,N'LoginMode'
 ,@AuthenticationMode OUTPUT

SELECT CASE @AuthenticationMode
  WHEN 1
   THEN 'Windows Authentication'
  WHEN 2
   THEN 'Windows and SQL Server Authentication'
  ELSE 'Unknown'
  END AS [Authentication Mode]

No comments:

Post a Comment