patternsqlMinor
Checking IFI enabled on SQL server below 2016
Viewed 0 times
enabledsqlcheckingbelowserverifi2016
Problem
I am using in one of my reports to check for status of IFI being enabled on SQL server.
It works well when using dmv
However, in SQL2014 and SQL2012 i see difficulties in rendering this check via SQL query.
For example if i use below
There is no guarantee it will show status on file '0' and sometimes i keep querying the error log manually to find that out. How can i achieve the IFI check using a better way so that it can show up on my SSRS report
It works well when using dmv
sys.dm_server_services for SQL2016However, in SQL2014 and SQL2012 i see difficulties in rendering this check via SQL query.
For example if i use below
EXEC sys.xp_readerrorlog 0, 1, N'Database Instant File Initialization';There is no guarantee it will show status on file '0' and sometimes i keep querying the error log manually to find that out. How can i achieve the IFI check using a better way so that it can show up on my SSRS report
Solution
According to this MSSQLTips.com article, you can use
For older versions, you'll need to scrape the log, looking for "Database Instant File Initialization: enabled."
sys.dm_server_services beginning with SQL 2012 SP4.SELECT @@SERVERNAME AS [Server Name] ,
RIGHT(@@version, LEN(@@version) - 3 - CHARINDEX(' ON ', @@VERSION)) AS [OS Info] ,
LEFT(@@VERSION, CHARINDEX('-', @@VERSION) - 2) + ' '
+ CAST(SERVERPROPERTY('ProductVersion') AS NVARCHAR(300)) AS [SQL Server Version] ,
service_account ,
instant_file_initialization_enabled
FROM sys.dm_server_services
WHERE servicename LIKE 'SQL Server (%'For older versions, you'll need to scrape the log, looking for "Database Instant File Initialization: enabled."
Code Snippets
SELECT @@SERVERNAME AS [Server Name] ,
RIGHT(@@version, LEN(@@version) - 3 - CHARINDEX(' ON ', @@VERSION)) AS [OS Info] ,
LEFT(@@VERSION, CHARINDEX('-', @@VERSION) - 2) + ' '
+ CAST(SERVERPROPERTY('ProductVersion') AS NVARCHAR(300)) AS [SQL Server Version] ,
service_account ,
instant_file_initialization_enabled
FROM sys.dm_server_services
WHERE servicename LIKE 'SQL Server (%'Context
StackExchange Database Administrators Q#235412, answer score: 4
Revisions (0)
No revisions yet.