Sometimes SQL developers want to put logic into their T-Sql code to check the SQL Server authentication mode. The SERVERPROPERTY() built in metadata system function can be used to identify the SQL Server authentication mode. SERVERPROPERTY() function with IsIntegratedSecurityOnly Property will return “1” for Windows authentication mode and “0” for Windows/SQL Authentication mode.
1 2 3 4 5 6 7 |
USE [master]; GO SELECT CASE SERVERPROPERTY('IsIntegratedSecurityOnly') WHEN 0 THEN 'SQL Server and Windows Authentication mode' WHEN 1 THEN 'Windows Authentication mode' ELSE 'Unknown' END as [SQL Server Authentication Mode] |
Leave a Comment