“Always Learning, Always Improving”
Cross
“Always Learning, Always Improving” | “கற்றது கைமண் அளவு, கல்லாதது உலகளவு” | “What you have learned is a mere handful of sand, but what you haven’t learned is the size of the world.”
MADURAIKARAN
“Love the Lord your God with all your heart and with all your soul and with all your strength.”
DB
VEERAKUMAR
Technology • Trading • Spirituality • History
Welcome to my journey

My Journey of Learning & Discovery

Technology | NSE Options Trading | Spirituality | World & Evolution | History

Sharing my personal journey, research, experiences and continuous learning across technology, NSE options trading, spirituality, world evolution and history.

Explore Blog → About Me
Veerakumar profile photo
DATA ENGINEERING
Microsoft SQL Server logo SQL SERVER
Oracle logo ORACLE
MySQL logo MySQL
Databases • ETL • Data Warehousing • Performance
DB

Technology

SQL Server, databases, AI, programming and the evolution of technology.

EXPLORE →

NSE Index Options Trading

NIFTY, BANK NIFTY, option strategies, trading psychology and my journal.

EXPLORE →

Spirituality

Personal reflections, philosophy, spirituality and questions about life.

EXPLORE →

World & Evolution

Human history, civilization, science and how the world and technology evolve.

EXPLORE →

Latest Articles

SQL scripts commonly used by DBAs in production server environments:

Some SQL scripts commonly used by DBAs in production server environments:

Script to Monitor Blocking Queries:

SELECT

    r.session_id,

    r.blocking_session_id,

    t.text AS [SQL Text]

FROM

    sys.dm_exec_requests r

    CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) t

WHERE

    r.blocking_session_id <> 0;

Script to Monitor Server Performance:

SELECT

    [object_name],

    [counter_name],

    [cntr_value]

FROM

    sys.dm_os_performance_counters

WHERE

    [object_name] LIKE '%:SQLServer%'

    AND [counter_name] IN ('Batch Requests/sec', 'Transactions/sec', 'User Connections')

ORDER BY

    [object_name], [counter_name];

Script to Identify Index Fragmentation:

SELECT

    dbschemas.[name] + '.' + dbtables.[name] AS [Table Name],

    dbindexes.[name] AS [Index Name],

    indexstats.avg_fragmentation_in_percent

FROM

    sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, NULL) AS indexstats

    INNER JOIN sys.tables dbtables ON dbtables.[object_id] = indexstats.[object_id]

    INNER JOIN sys.schemas dbschemas ON dbtables.[schema_id] = dbschemas.[schema_id]

    INNER JOIN sys.indexes AS dbindexes ON dbindexes.[object_id] = indexstats.[object_id] AND indexstats.index_id = dbindexes.index_id

WHERE

    indexstats.avg_fragmentation_in_percent > 10

ORDER BY

    indexstats.avg_fragmentation_in_percent DESC;

Script to Find High CPU Queries:

SELECT TOP 10

    total_worker_time/execution_count AS Avg_CPU_Time,

    total_worker_time AS Total_CPU_Time,

    execution_count,

    creation_time,

    last_execution_time,

    st.text AS [SQL Text]

FROM

    sys.dm_exec_query_stats AS qs

    CROSS APPLY sys.dm_exec_sql_text(qs.[sql_handle]) AS st

ORDER BY

    total_worker_time/execution_count DESC;

Script to Check Database Size and Space Usage:

EXEC sp_MSforeachdb '

    USE [?];

    SELECT

        DB_NAME() AS [Database Name],

        (size * 8) AS [Size (KB)],

        FILEGROUP_NAME(data_space_id) AS [Filegroup],

        name AS [Logical Name],

        (size * 8 - FILEPROPERTY(name, ''SpaceUsed'') * 8) AS [Unused Space (KB)]

    FROM

        sys.master_files

    WHERE

        type = 0;

    ';




No comments:

I would like to share with you what I have learned and I hope it will be useful for you. _V€€RAKUMAR

Mastering SQL Server

Search This Blog

Powered by Blogger.

Mastering SQL Server

Labels


Translate

Restarting my career from where I left off. With hands-on experience as a Microsoft SQL Server DBA, I have developed skills in database mana...