Ubuntu

some daily operational tasks:

MySQL database performance

Database sizes and number of tables:

Database total size:

Recent Database Activity

Rename and archive databases to name _old and move the datafiles and tr log files to old subfolder

Sometime the application installation want to create the same databases with the same data files.
In this case we need to rename them and move another folder not to update.

This PowerShell script renames two local SQL Server databases (database1 and database2),
Closes active connections with SINGLE_USER, detaches, moves their files to an “old” subfolder in their current location,
Reattaches them. All PowerShell output and commands are logged to Documents\log.

The SQL Server Network Interface library could not register the Service Principal Name (SPN) for the SQL Server service. Windows return code0x21c7, state: 15

Message
The SQL Server Network Interface library could not register the Service Principal Name (SPN) [ MSSQLSvc/computername1.contoso.local:1433 ] for the SQL Server service. Windows return code: 0x21c7, state: 15. Failure to register a SPN might cause integrated authentication to use NTLM instead of Kerberos. This is an informational message. Further action is only required if Kerberos authentication is required by authentication policies and if the SPN has not been manually registered.

This message occurs when an existing spn (for computer) was registered.

Soludtion
Delete the existing computer account spn:

and register the service account if it is missing:

Missing index

New SQL DMV in SQL server 2019

— Selectivity from mssqltips.com

 

Check the SQL Server version

There are always some new features in the database server, which has SQL version checking requirements. For example: GRANT VIEW DATABASE PERFORMANCE STATE TO [user] can run, if your server at least SQL Server 2022.

In this case if you don’t want to see error in an older version , you have to check it:

 

 

DateTime calculator to UTC to Local Server time to a specific TimeZone

In SQL server you can get the local datetime UTC time . Convert it to different TimeZone:

 

Convert a local datetime or the server local time to different timezone:

Convert  UTC datetime or the server  UTC time to different timezone:

Continue reading “DateTime calculator to UTC to Local Server time to a specific TimeZone”

Install Oracle in docker

Install Oracle express

docker command in windows powershell (WSL installed):

download oracle sqldeveloper Windows 64-bit with JDK 11 included:

https://www.oracle.com/database/sqldeveloper/technologies/download/

Add read rights to all existing and new user databases

 

The following script add read user rights for every user databases and  system model databases for the new databases to readeruser  login.

 

Resolve SID to domain account

There are reasons you need to resolve SID. You can do it by powershell: