Saturday, December 31, 2022

SQL Server - MSSQL - Environment

Here is the concept to create MSSQL - Environment with Expiry



 

--|Calculator | 


Use [WaterMark]


CREATE TABLE MSSQL_Environment

(

[id] INT IDENTITY(1,1), 

[Instance] NVARCHAR(256),

[is_default] char(3),

[Edition] NVARCHAR(256) NULL,

[Create_Date] datetime

)


insert into MSSQL_Environment (Instance,is_default,edition,create_date)

select @@SERVERNAME,'No',@@VERSION,GETDATE()


update MSSQL_Environment set Create_Date=(select create_date FROM sys.server_principals sp WHERE sp.name = 'NT AUTHORITY\SYSTEM')


-- Below is the query to get Acorate Expiry


SELECT instance,is_default,edition,

create_date AS 'SQL Server Installed Date', 

Expiry_date AS 'SQL Server Expiry Date',

DATEDIFF(dd,create_date, GETDATE()) 'No_of_Days_Used', 

ABS(DATEDIFF(dd,expiry_date,GETDATE())) 'No_Of_Days_Left'

FROM (SELECT instance,is_default,edition,sp.create_date, DATEADD(dd, 180, sp.create_date) AS Expiry_date FROM MSSQL_Environment sp ) as exp_date


Remember:- There is no point to write iTea when we belong to IT Industry.


Best Regards


Amit Vaid 'ya' Amit

Note:- Below email account is going to be discontinued.

@SQLDBASupport


No comments: