Hey guys,
How are you?

In this post I will demonstrate how to find out when the SQL Server instance was installed and, if you are using the trial / evaluation license, what is the expiration date.

This is very important to know, because when that date arrives, your instance (and all databases on it) will STOP WORKING. That's right, your data will be inaccessible until you purchase a license and upgrade the license (do you want to buy a SQL Server license at the lowest possible price? Click here).

To find out when your trial version of SQL Server will expire, simply run the query below:

-- Verificando a data de expiração do SQL Server (180 dias após instalação)
SELECT
    @@SERVERNAME AS [Server_Name],
    @@SERVICENAME AS [Service_Name],
    SERVERPROPERTY('Edition') AS [Edition],
    [create_date] AS [SQL Server Installation Date],
    (CASE WHEN CONVERT(VARCHAR(MAX), SERVERPROPERTY('Edition')) LIKE '%Evaluation%' THEN DATEADD(DAY, 180, [create_date]) ELSE NULL END) as [SQL Server Expiration Date],
    DATEDIFF(DAY, [create_date], GETDATE()) AS [Days_Used],
    (CASE WHEN CONVERT(VARCHAR(MAX), SERVERPROPERTY('Edition')) LIKE '%Evaluation%' THEN DATEDIFF(DAY, GETDATE(), DATEADD(DAY, 180, [create_date])) ELSE NULL END) AS [Days_Left]
FROM
    sys.server_principals
WHERE
    sid = 0x010100000000000512000000 -- NT AUTHORITY\SYSTEM

Query result:

That's it, folks!
A hug and see you in the next post.