Sunday, March 8, 2026

SQL Server 2025 Regular expressions functions

 

Core Regex Functions

The system provides several functions to search, modify, and analyze strings using patterns:

FunctionPurpose
REGEXP_LIKEReturns True if the text matches the pattern.
REGEXP_REPLACEModifies a string by replacing matches with a new value.
REGEXP_SUBSTRExtracts a specific occurrence of a matching substring.
REGEXP_INSTRReturns the position (start or end) of a match.
REGEXP_COUNTCounts how many times a pattern appears.
REGEXP_MATCHESReturns a table of all captured substrings.
REGEXP_SPLIT_TO_TABLESplits a string into a table using the pattern as a delimiter.

Syntax and Construction

Regex patterns are built using literal characters (which match themselves) and metacharacters (which have special logic).

  • Escaping: To match a literal metacharacter (like * or ?), you must use a backslash (\*).

  • Concatenation & Alternation: * e1 e2 matches "e1" followed by "e2".

    • e1 | e2 matches either "e1" or "e2".

  • Repetition Operators:

    • *: Zero or more matches.

    • +: One or more matches.

    • ?: Zero or one match.

  • Precedence: Operators follow a specific order of strength: Repetition (strongest) > Concatenation > Alternation (weakest). Parentheses () can be used to override this order.

let's assume we are working with a string representing a standard product code: Item_#1234-Blue.

 Examples

  • REGEXP_LIKE (The Filter)

    • Goal: Check if a string contains a 4-digit number.

    • Pattern: \d{4}

    • Result: True (since 1234 matches).

  • REGEXP_SUBSTR (The Extractor)

    • Goal: Pull the color name from the end of the string.

    • Pattern: [^-]+$ (Matches characters after the last hyphen).

    • Result: Blue

  • REGEXP_REPLACE (The Cleaner)

    • Goal: Remove the hash symbol (#).

    • Pattern: #

    • Replacement: '' (Empty string).

    • Result: Item_1234-Blue

  • REGEXP_COUNT (The Auditor)

    • Goal: Count how many times a hyphen appears.

    • Pattern: -

    • Result: 1

Cheers
Samitha

Saturday, February 21, 2026

GitHub Copilot in SQL Server (Preview)

GitHub Copilot for SQL Server Management Studio (SSMS) integrates AI directly into your database environment to streamline T-SQL development. Here is a summary of how it works and what it offers:

How it Works

The integration connects your GitHub Copilot account to SSMS. When you submit a prompt, SSMS sends it to the selected AI model along with contextual metadata—such as your SQL version and database schema—to ensure the generated code is accurate and relevant to your specific environment.

Key Features

  • Interactive Chat: Use a dedicated chat window or an inline chat view to ask questions using natural language.

  • T-SQL Assistance: Generate, fix, or optimize SQL queries on the fly.

  • Slash Commands: Use quick shortcuts for specific tasks:

    • /doc: Automatically document your code.

    • Explain: Get a breakdown of complex queries.

    • Fix/Optimize: Improve query performance or resolve errors.

Note: This feature is currently in Preview. You will need an active GitHub Copilot subscription and the latest SSMS preview installation to use it. 

Cheers,

Samitha

Wednesday, January 14, 2026

npm run build does not work

If you are experiencing building js files for production follow these steps
  •  Make sure you have the correct node version
          execute node -v in PowerShell / Command Prompt / VS Code terminal
  • Delete node_modules 
  • Delete package-lock.json
  • Install correct node version
  • Restart the Terminal (This step is required on Windows so PATH updates correctly)
  • execute npm install in PowerShell / Command Prompt / VS Code terminal
  • execute npm run dev in PowerShell / Command Prompt / VS Code terminal

Cheers
Samitha

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

Sunday, November 30, 2025

SQL Server OUTER APPLY

 OUTER APPLY is a powerful operator used to join each row from an outer table to the results of a table-valued function or subquery. It behaves like a LEFT JOIN, but works with correlated subqueries that return multiple columns.

OUTER APPLY:

  • Evaluates the right-hand subquery for each row of the left table.

  • Returns all rows from the left table.

  • Returns matching rows from the APPLYed subquery — or NULLs when the subquery returns nothing.

It’s similar to:

Operator                      Behavior
CROSS APPLY         Like INNER JOIN
OUTER APPLY         Like LEFT JOIN


E.g
SELECT 
    c.CustomerID,
    c.Name,
    o.OrderID,
    o.OrderDate
FROM Customers c
OUTER APPLY (
    SELECT TOP(1) *
    FROM Orders o
    WHERE o.CustomerID = c.CustomerID
    ORDER BY o.OrderDate DESC
) o;


Cheers

Samitha 

Sunday, November 16, 2025

Copilot vs ChatGPT vs Gemini AI

 

 

Choosing between Microsoft Copilot, ChatGPT, and Gemini AI depends on your environment and what you need the AI to do.

  • Microsoft Copilot is the best fit for organizations deeply using the Microsoft 365 ecosystem. It excels at structured, context-based tasks such as automating Power BI workflows, assisting in Teams, and enhancing productivity and collaboration across Office apps.

  • ChatGPT is the most versatile and flexible option. It suits creatives, educators, developers, and businesses needing customizable solutions for content creation, brainstorming, coding, or general problem-solving. Its adaptability makes it ideal for both individuals and startups across many industries.

  • Gemini AI shines with its multimodal strengths and smooth integration into Google Workspace. It’s excellent for multimedia content creation, real-time insights, and team collaboration—making it a great choice for marketing teams, creative professionals, and companies already using Google’s ecosystem.

Ultimately, the right tool depends on your tech stack, your workflow, and the type of AI assistance you require.


Cheers

Samitha