Monday, December 29, 2025

SQL Server 2025 fuzzy string matching(preview)

 Fuzzy (approximate) string matching compares two strings Chto determine how similar they are and to measure their differences. It is used to identify strings that may vary due to character corruption, such as spelling mistakes, transposed or missing characters, or the use of abbreviations. This technique relies on algorithms that detect similarity based on character patterns or phonetic likeness, enabling the matching of strings that sound alike or are nearly identical despite minor variations.


Check here for samples

Samitha

Saturday, December 20, 2025

SQL Server LAG() Function

 The SQL LAG() function is a window function used to access a column’s value from a previous row within a defined partition and order. Unlike aggregate functions, it does not reduce the number of rows; instead, it returns a corresponding value for each row. By specifying a partition (e.g., by organisation) and an order (e.g., by year), LAG() enables row-by-row comparisons, such as comparing current values with prior-period values


E.g

SELECT 

    Department,

    Employee,

    SalaryMonth,

    Salary,

    LAG(Salary, 1, 0) 

        OVER (PARTITION BY Department ORDER BY SalaryMonth) AS PrevMonthSalary

FROM EmployeeSalary

ORDER BY Department, SalaryMonth

Result

DepartmentEmployeeSalaryMonthSalaryPrevMonthSalary
ITJohn2024-011200000
ITJohn2024-02125000120000
ITJohn2024-03130000125000
HRMary2024-01900000
HRMary2024-029200090000
HRMary2024-039500092000