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

Thursday, November 6, 2025

GitHub Copilot

 GitHub Copilot is an AI-powered coding companion that helps with code completion, editing, reviewing, documenting, and managing projects, while offering customization, enterprise control, and integration across multiple development environments.


Core Coding Features

  • Code Completion:
    Autocomplete-style code suggestions in supported IDEs (VS Code, Visual Studio, JetBrains, etc.).
    VS Code also supports next edit suggestions to predict your next likely edit.

  • Copilot Chat:
    AI chat assistant for coding help, available in IDEs, GitHub.com, GitHub Mobile, and Windows Terminal.
    Supports “skills” for specialized tasks.

  • Copilot Edits:
    Lets Copilot modify code directly across multiple files.

    • Edit Mode: User controls files and iterations (for precise updates).

    • Agent Mode: Copilot autonomously edits and iterates to complete complex tasks.

  • Copilot Coding Agent:
    An autonomous AI that can make code changes, resolve issues, and create pull requests automatically.

  • Copilot CLI (Public Preview):
    Command-line tool for asking Copilot questions, editing local files, and managing GitHub issues or pull requests.

Collaboration & Review

Customization & Extensions

Advanced Tools

  • GitHub Spark (Preview):
    Build and deploy full-stack apps using natural language prompts.

  • Copilot Coding Agent (Advanced):
    Executes multi-step coding tasks, handles errors, and integrates with external systems.

Enterprise & Admin Features

  • Policy Management:
    Control which Copilot features are enabled across orgs and enterprises.

  • Access Management:
    Define who can use Copilot within organizations.

  • Usage Data & Audit Logs:
    Track adoption, usage metrics, and user activity for governance.

  • Exclude Files:
    Prevent Copilot from accessing sensitive or irrelevant files.


Cheers
Samitha

Sunday, October 5, 2025

Securing Connection Strings & AppSettings in ASP.NET Core

 ASP.NET Core apps use appsettings.json to store configuration like connection strings, API keys, and secrets. If unprotected, these can expose sensitive data.

Why Security Matters

  • Connection strings often include DB usernames & passwords.

  • API keys/secrets can unlock external services.

  • Misconfigurations may leak data in logs or errors.

  • Compromised values can lead to data theft, privilege escalation, or abuse.

Default Configuration Sources

  • appsettings.json

  • appsettings.{Environment}.json

  • Environment variables

  • User Secrets (development)

  • Key vaults/Secrets managers (production)

Security Options

  1. User Secrets (Dev Only)

    • Stored locally, not in source control.

    • dotnet user-secrets set "ConnectionStrings:DefaultConnection" "..."

  2. Environment Variables

    • Safer than JSON files, follows 12-factor app principles.

    • Example (PowerShell):

      $env:ConnectionStrings__DefaultConnection="..."
  3. Cloud Secret Managers (Production)

    • Azure Key Vault

      builder.Configuration.AddAzureKeyVault( new Uri($"https://{builder.Configuration["KeyVaultName"]}.vault.azure.net/"), new DefaultAzureCredential());
    • AWS Secrets Manager

      var secret = await secretsManager.GetSecretValueAsync( new GetSecretValueRequest { SecretId = "MyApp-DbConnection" });


Best Practice: 

Use User Secrets for local dev, Environment Variables for staging, and a Cloud Secret Manager for production.


Cheers

Samitha

Sunday, September 7, 2025

SQL Server 2025 (preview) working with JSON

 


Working with JSON in SQL Server

SQL Server allows you to store JSON text in database tables and use built-in functions to query or modify it using standard T-SQL.


1. Extract Values from JSON

You can extract values using:

JSON_VALUE: Returns a scalar value (e.g., string, number).

JSON_QUERY: Returns an object or array.


E.g.

SELECT JSON_VALUE(jsonCol, '$.info.address.Town') AS Town

FROM People

WHERE ISJSON(jsonCol) > 0;


SELECT JSON_QUERY(jsonCol, '$.info.skills') AS Skills

FROM People;


2. Modify JSON Data

Use JSON_MODIFY to update parts of a JSON string.


E.g


DECLARE @json NVARCHAR(MAX);

SET @json = '{"city":"Paris"}';

SET @json = JSON_MODIFY(@json, '$.city', 'London');

SELECT @json AS ModifiedJson;

-- Result: {"city":"London"}



3. Convert JSON to Rowset

Use OPENJSON to transform JSON arrays into tabular data.


E.g


DECLARE @json NVARCHAR(MAX) = N'[

  {"id": 1, "name": "Alice"},

  {"id": 2, "name": "Bob"}

]';


SELECT *

FROM OPENJSON(@json)

WITH (

    id INT,

    name NVARCHAR(100)

);


4. Validate JSON

E.g

Checks if a string is valid JSON (returns 1 if true).


SELECT ISJSON('{"name":"value"}') AS IsJson; -- Returns 1

SELECT ISJSON('invalid') AS IsJson;          -- Returns 0


5. Combined JSON

SELECT 

  Name,

  JSON_VALUE(jsonCol, '$.info.address.Town') AS Town,

  JSON_QUERY(jsonCol, '$.info.skills') AS Skills

FROM People

WHERE ISJSON(jsonCol) = 1

  AND JSON_VALUE(jsonCol, '$.info.address.Town') = 'Belgrade';



Cheers

Samitha