November 2020

Restore database in SQL Server TSQL Statement

Here I am trying to explain how we find backup files and related information in SQL Query. Below query shows the top 100 records from backup history order by latest date Replace database name with your database name or remove from query. Below query containing information about the backup media from backup full file name. …

Restore database in SQL Server TSQL Statement Read More »

Difference between row_number(), rank() and dense_rank() window functions in SQL Server

All Three function work as per order by clause The row_number() function always generates a unique ranking even with duplicate records. RANK() behaves like ROW_NUMBER(), except that “equal” rows are ranked the same. Dense_Rank() Function is similar to Rank with the only difference, this will not leave gaps between groups. Other References https://docs.microsoft.com/en-us/sql/t-sql/queries/table-value-constructor-transact-sql?view=sql-server-ver15