Hash Index

What is a ‘HASH INDEX’ in SQL? A Hash Index is a specific type of index that works best for equality comparisons. It uses a hash function to distribute rows evenly across a specified number of buckets. The hash function takes column values as input and returns a bucket number. When a query involving an... » read more

Recreating MSSQL Always On using SSMS AlwaysOn Wizard

Recreating Always On from an existing setup using SSMS AlwaysOn Wizard. Note: Delete all database and database files on secondary servers. Make sure all drive and folder mapping are the same as primary server. Use Local drive or NAS drive for AlwaysOn backup file location. Make sure existing database backup jobs has been disabled. Might... » read more

Restore Database from full, differential, and log backup files.

https://learn.microsoft.com/en-us/sql/relational-databases/backup-restore/restore-a-differential-database-backup-sql-server?view=sql-server-ver16 RESTORE WITH NORECOVERY which leaves the database non-operational, and does not roll back the uncommitted transactions. Additional transaction logs can be restored. The database cannot be used until it is recovered. Examples (Transact-SQL) A. Restoring a differential database backup This example restores a database and differential database backup of the MyAdvWorks database. B. Restoring a database, differential... » read more

Upgrade availability group replicas

https://learn.microsoft.com/en-us/sql/database-engine/availability-groups/windows/upgrading-always-on-availability-group-replica-instances?view=sql-server-ver16 When upgrading a SQL Server instance that hosts an Always On availability group (AG) to a new SQL Server version, to a new SQL Server service pack or cumulative update, or when installing to a new Windows service pack or cumulative update, you can reduce downtime for the primary replica to only a single... » read more

Things to Avoid in Your Query

LIKE ‘%xxxxxx%’ https://www.brentozar.com/archive/2010/06/sargable-why-string-is-slow/ Table Valued Functions https://www.brentozar.com/blitzcache/tvf-join/ Functions in from/below Implicit Conversions (convert to different data type) Comparing the contents of 2 columns on 1 table Table Variables Table variable does not have stats and serial for updates.

CTE (Common Table Expression)

https://learn.microsoft.com/en-us/sql/t-sql/queries/with-common-table-expression-transact-sql?view=sql-server-ver16 Specifies a temporary named result set, known as a common table expression (CTE). This is derived from a simple query and defined within the execution scope of a single SELECT, INSERT, UPDATE, DELETE or MERGE statement.  A Common Table Expression, also called as CTE in short form, is a temporary named result set that... » read more

SQL Server Windows Failover Cluster – Unable to start Roles

Status: Windows Failover Cluster fail to start any of the Roles All nodes in the Windows Failover Cluster are up. Identified several important event IDs that are common across all SQL nodes: 1069, 1205, 1254. Probable Causes: -SQL node names and AG name are not resolving or couldn’t register in the network. please look at the... » read more