Sunday, March 16, 2025

MSSQL Common blogs & Queries

MSSQL Reference Blogs:

KendraLittle.com

https://www.sqlshack.com/t-sql-scripts-to-update-statistics-based-on-the-row-modification/

SQL Server statistics – modification counter – SQL Service

 MSSQL Common Queries:

https://docs.google.com/document/d/1AYl7gBAdLYwXqSOpHX3s0UhC1YF-UL27/edit?usp=sharing&ouid=108977388436519456629&rtpof=true&sd=true



Wednesday, March 12, 2025

Format complex sql and plsql codes using sqlinform notepad++ plugin

 Objective: format complex sql and plsql codes using sqlinform notepad++ plugin


The objective of this video is to quickly show how to quickly format multiline sql or plsql code poorly formatted for example the whole code is present in 1 line with carriage return or the code isnt in readable form.


Solution to use: sqlinform plugin for notepad++ [ the same tool is available for visual studio, dbeaver etc.. ]


Download source: https://www.sqlinform.com/download-free-notepad-plugin/


Steps:

1. Download 32bit of 64bit of your requirement

2. Open notepad++, findout the plugin location

3. Create a folder called SQLinFormNpp or SQLinFormNpp64 and then copy the downloaded plugin over here

4. Restart the notepad++

5. Now choose the sql file ill formated and start beautifying it :)



Reference: https://stackoverflow.com/questions/75032400/notepadd-plugin-sqlinform-for-sql-formatting-bright-orange-color-background


Thanks


Thursday, March 6, 2025

SQL Server File System Layout

SQL Server File System Layout

├─── Central Theme: Separation, Organization, Performance, Manageability

├─── 📂 Operating System Volume (C:\)

│   ├─── Purpose: Windows OS, Paging File, essential system files

│   ├─── RAID:  OS volume - RAID 1 (Mirroring) is good, but not performance critical for SQL Server

│   └─── Contents:

│       ├─── Windows OS Files

│       ├─── Pagefile.sys

│       └─── (Ideally) Minimal Application Data - Keep C:\ clean

├─── 💾 Binary Volume (S:\  - Example, can be other drive letter)  <-- **Custom Binary Path!**

│   ├─── Purpose: SQL Server Program Files (Binaries)

│   ├─── RAID:  Not performance critical, RAID 1 or even single disk is acceptable. Focus on redundancy over speed for binaries.

│   └─── Contents:

│       └─── S:\SQLBinaries\ (Example Root Folder)

│           ├─── MSSQL16.INSTANCE1\ (Instance Root Directory - e.g., MSSQL16.MSSQLSERVER)

│           │   ├─── MSSQL\ (SQL Server Engine Binaries)

│           │   ├─── Binn\  (Executable binaries)

│           │   ├─── <... other binary folders and files ...>

│           └─── MSSQL16.INSTANCE2\ (For Named Instance "INSTANCE2")

│               └─── ...

├─── 🗄️ Data Volume(s) (D:\, E:\, F:\...)

│   ├─── Purpose: SQL Server Data Files (.mdf, .ndf) for user databases

│   ├─── RAID:  RAID 10 (Recommended for performance and redundancy), RAID 5/6 acceptable for read-heavy workloads

│   └─── Directory Structure (Example for D:\)

│       └─── D:\SQLData\

│           ├─── INSTANCE1\

│           │   ├─── Database1\

│           │   │   ├─── Database1.mdf

│           │   │   ├─── Database1_02.ndf

│           │   │   └─── ...

│           │   ├─── Database2\

│           │   │   ├─── Database2.mdf

│           │   │   └─── ...

│           │   └─── ...

│           └─── INSTANCE2\

│               └─── ...

├─── 📜 Log Volume(s) (L:\, M:\, N:\...)

│   ├─── Purpose: SQL Server Transaction Log Files (.ldf) for user databases

│   ├─── RAID:  RAID 10 (Recommended for optimal write performance and redundancy)

│   └─── Directory Structure (Example for L:\)

│       └─── L:\SQLLogs\

│           ├─── INSTANCE1\

│           │   ├─── Database1\

│           │   │   └─── Database1_log.ldf

│           │   ├─── Database2\

│           │   │   └─── Database2_log.ldf

│           │   └─── ...

│           └─── INSTANCE2\

│               └─── ...

├─── TempDB Volume(s) (T:\, U:\, V:\...)  <-- Separate Data & Log!

│   ├─── Purpose: TempDB Data and Log files - **CRITICAL for Performance**

│   ├─── RAID:  Fast Storage (SSDs ideal if possible). RAID 10 or RAID 0 (Data - carefully consider), RAID 10 (Log)

│   └─── Directory Structure:

│       ├─── T:\TempDBData\  (TempDB Data Files)

│       │   └─── INSTANCE1\

│       │       ├─── TempDB_Data1.mdf

│       │       ├─── TempDB_Data2.ndf  (Multiple files recommended)

│       │       └─── ...

│       └─── U:\TempDBLog\  (TempDB Log File - Separate Disk/Volume from Data)

│           └─── INSTANCE1\

│               └─── TempDB_log.ldf

├─── 💾 Backup Volume(s) (B:\, P:\, Q:\...)

│   ├─── Purpose: SQL Server Backup Files (.bak, .trn)

│   ├─── RAID:  RAID 5, RAID 6, or RAID 10 (depending on needs) - Capacity and reasonable speed

│   └─── Directory Structure (Example for B:\)

│       └─── B:\SQLBackups\

│           ├─── INSTANCE1\

│           │   ├─── Database1\

│           │   │   ├─── Full\

│           │   │   │   └─── Database1_Full_YYYYMMDD.bak

│           │   │   ├─── Diff\

│           │   │   │   └─── Database1_Diff_YYYYMMDD.bak

│           │   │   └─── Log\

│           │   │       └─── Database1_Log_YYYYMMDD.trn

│           │   ├─── Database2\

│           │   │   └─── ...

│           │   └─── ...

│           └─── INSTANCE2\

│               └─── ...

├─── 🗂️ Full-Text Catalog Volume (Optional - F:\)

│   ├─── Purpose: Full-Text Catalog files (if used heavily)

│   ├─── RAID:  SSD or RAID 10 for performance if full-text search is critical

│   └─── Directory Structure (Example for F:\)

│       └─── F:\SQLFTCatalogs\

│           ├─── INSTANCE1\

│           │   ├─── Database1\

│           │   │   ├─── Catalog1\

│           │   │   └─── <Full-Text Catalog Files>

│           │   └─── ...

│           └─── INSTANCE2\

│               └─── ...

├─── 📂 FileStream/FileTable Volume (Optional - W:\)

│   ├─── Purpose: FileStream/FileTable data (if used heavily)

│   ├─── RAID:  Depends on workload (RAID 5, 6, or 10)

│   └─── Directory Structure (Example for W:\)

│       └─── W:\SQLFileStream\

│           ├─── INSTANCE1\

│           │   ├─── Database1\

│           │   │   ├─── FileStreamData1\

│           │   │   └─── <FileStream Files>

│           │   └─── ...

│           └─── INSTANCE2\

│               └─── ...

└─── 📝 Error/Trace Log Volume (Optional - E:\, TR:\)

    ├─── Purpose: SQL Server Error Logs, Trace Files, etc.

    ├─── RAID:  Less critical, standard storage acceptable

    └─── Directory Structure:

        ├─── E:\SQLErrors\  (Error Logs)

        │   └─── INSTANCE1\ (or just root if single instance)

        │       ├─── Errorlog.log

        │       ├─── Errorlog.1

        │       └─── ...

        └─── TR:\SQLTraces\ (Trace Files)

            └─── INSTANCE1\ (or just root if single instance)

                ├─── TraceFile_YYYYMMDD.trc

                └─── ...



* **Drive Letters are Examples:**  Use drive letters that are available. Mount points are an alternative.

* **Instance Specific Folders:**  Structure includes instance-specific folders if you have multiple SQL Server instances on the same server, making it organized.

* **Optional Volumes:**  Full-Text, FileStream, and Error/Trace Log volumes are optional and depend on your usage and needs.

* **Binary Path Highlight:** The "Binary Volume (S:\)" clearly illustrates the custom path for SQL Server binaries, moved off the C:\ drive.

* **RAID Recommendations are General:**  Choose RAID levels based on your specific performance, redundancy, and budget requirements. RAID 10 is frequently recommended for Data and Logs.

* **Adapt to Your Needs:** This is a template; adjust the number of volumes, drive letters, RAID levels, and optional volumes based on your specific SQL Server environment and hardware.


Tuesday, March 4, 2025

Azure Deployment Cost Comparison between various deployments

 url: DocHere

Microsoft Azure Estimate
Your Estimate
Service categoryService typeCustom nameRegionDescriptionEstimated monthly costEstimated upfront cost
ComputeVirtual MachinesNorth Europe1 D4ads v5 (4 vCPUs, 16 GB RAM) x 744 Hours (Pay as you go), Linux, On Demand (AHB); 1 managed disk – P20; Inter Region transfer type, 5 GB outbound data transfer from North Europe to East Asia$244.34$0.00
ComputeVirtual MachinesNorth Europe1 D4ads v5 (4 vCPUs, 16 GB RAM) x 744 Hours (Pay as you go), Windows (Licence included), SQL Enterprise (Pay as you go); 1 managed disk – P20; Inter Region transfer type, 5 GB outbound data transfer from North Europe to East Asia$244.34$0.00
DatabasesAzure Database for PostgreSQLNorth EuropeFlexible Server Deployment, General Purpose Tier, 1 D4ads v5 (4 vCores) x 744 Hours (Pay as you go), Storage - Premium SSD, 500 GiB Storage, 100 Provisioned IOPS, 0 GiB Additional Back-up storage - LRS redundancy, with High Availability$769.56$0.00
SupportSupport$0.00$0.00
Licensing ProgramMicrosoft Customer Agreement (MCA)
Billing Account
Billing Profile
Total$1,258.24$0.00

Flashback data archive steps

 Objective: Ways to track DML changes in a table Detailed objective: We should be able to track the changes in the table at any point in tim...