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.

 

DBATools Get-DbaDatabase] Failure | The certificate chain was issued by an authority that is not trusted.

If  you get the error:

Get-DbaDatabase] Failure | The certificate chain was issued by an authority that is not trusted.

You can set in dbatools:

 

or

 

dbatools sql The certificate chain was issued by an authority that is not trusted.
dbatools sql The certificate chain was issued by an authority that is not trusted.

SQL Server using Active Directory Kerberos authentication on RedHat linux

This is an SSMS screenshot where a SQL user and two (windows) domain users connected to SQL Server:

SQL Server on Red Hat Linux using kerberos AD authentication
SQL Server on Red Hat Linux using kerberos AD authentication

some hint if you want to deploy it:
– at first you have to join the linux server to the Active Directory
sudo realm join SQLPLAYGROUND.COM -U ‘azureadmin’ -v
kinit and klist help you to check kerberos tickets
– you can use create -k /var/opt/mssql/secrets/mssql.keytab only in Ubuntu
– you have to use ktpass /princ MSSQLSvc/REDHATSQL2019.SQLPLAYGROUND.COM:1433@CONTOSO.COM /ptype KRB5_NT_PRINCIPAL /crypto aes256-sha1 /mapuser SQLPLAYGROUND\sqluser /out mssql.keytab -setpass -setupn /kvno /pass in Red-Hat linux

Index usage statistics

Do you have unused index? Do you have ineffective index? How many times was it used for select or update?
Is it used by scan , seeks or lookups?
Index usage statistics :

How to start a stored procedure when SQL server start?

You can start a stored procedure that is set to automatic execution runs every time an instance of SQL Server is started.

Is there any autostart stored procedure on your SQL Server?
You can query:

Replace a MS SQL Database in AlwaysOn AG with DBATools

There is a database in AG and you need to drop it and restore from backup (which is sometimes a transition from developer to prod )
You don’t need any prerequisite for cluster nodes and AG names.
The script find the instance in local windows server and find the db AG nodes and listener.
So finally you need the database name and the location of the backup folder which can be an Ola backup solution folder.

Setup.exe error with using ConfigurationFile.ini

SQL server setup error with using setup.exe /CONFIGURATIONFILE=D:\Install\ConfigurationFile.ini

Error message:
Error result: -2054422506
Result facility code: 1420
Result error code: 22

Please check the ini file:

Reason:
; Setup will not display any user interface.
QUIET=”True”
; Setup will display progress only, without any user interaction.
QUIETSIMPLE=”False”
; Parameter that controls the user interface behavior. Valid values are Normal for the full UI,AutoAdvance for a simplied UI, and EnableUIOnServerCore for bypassing Server Core setup GUI block.
UIMODE=”Normal”

Possible Solution :
QUIET=”False”

SQL AO AG failover in cluster group and check the synchronization status

Get info from Cluster:

Failover general example, you can use Invoke-DbaAgFailover for SQL server:

DBATools makes your life happy, you can find the SQL server instances and you can failover them.

To find  all of the SQL instances in a cluster server . To Check AG before and after the failover, and failover the SQL Server AO AG :


 

if you have to wait a lot for synchronization you can check how many servers are synchronized.


 

 

What is my default backup BUFFERCOUNT and MAXTRANSFERSIZE Data Transfer Options?

Error message: BackupIoRequest::ReportIoError: write failure on backup device \\filer\sharename\.. bak Operating system error 8(Not enough memory resources are available to process this command.).

It may you want a better performance for backup (less cpu and shorter backup time, so you can tune the BUFFERCOUNT  and MAXTRANSFERSIZE

https://docs.microsoft.com/en-us/sql/t-sql/statements/backup-transact-sql?view=sql-server-ver15
–Data Transfer Options BUFFERCOUNT = { buffercount | @buffercount_variable } | MAXTRANSFERSIZE = { maxtransfersize | @maxtransfersize_variable }

Books Online gives the following definition for these two options:

BUFFERCOUNT = { buffercount | @ buffercount_variable }

Specifies the total number of I/O buffers to be used for the backup operation. You can specify any positive integer; however, large numbers of buffers might cause “out of memory” errors because of inadequate virtual address space in the Sqlservr.exe process.

Based on the values that you provide or do not provide, SQL Server specifies the size contiguous buffers that it will use to perform the backup. This is of utmost importance in 32-bit environments as large amount of contiguous memory allocation can prove to be fatal to the non-Buffer Pool region of the SQL Virtual Address Space. This can cause your backups to fail. When SQLVDI is being used, this is of utmost importance because we cannot change the MAXTRANSFERSIZE after the VDI Configuration has been completed. The amount of contiguous virtual memory is determined by the number of backup devices and by the number of volumes on which the database files reside on.

You can use Trace Flag 3213 to review your backup/restore configuration parameters while performing a backup/restore operation. I shall proceed to show you how specifying the incorrect BUFFERCOUNT values or not providing it can prove to be fatal.

So how to get the buffercount?

Sample result:

out of memory backup BUFFERCOUNT and MAXTRANSFERSIZE
out of memory backup BUFFERCOUNT and MAXTRANSFERSIZE