“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 that may be helpful for MS SQL Server DBAs in their daily tasks:

 SQL scripts that may be helpful for MS SQL Server DBAs in their daily tasks:

1.Script to Backup a Database:

BACKUP DATABASE [YourDatabaseName]

TO DISK = 'C:\Backup\YourDatabaseName.bak'

WITH INIT, FORMAT, COMPRESSION;

2.Script to Restore a Database:

RESTORE DATABASE [YourDatabaseName]

FROM DISK = 'C:\Backup\YourDatabaseName.bak'

WITH REPLACE, RECOVERY;

3.Script to Check Database Integrity:

DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS;

Script to Shrink Transaction Log File:

DBCC SHRINKFILE ('YourDatabaseName_log', 1);

SELECT

    r.session_id,

    r.start_time,

    r.status,

    r.command,

    t.text AS [SQL Text]

FROM

    sys.dm_exec_requests r

    CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) t

WHERE

    r.status NOT IN ('background', 'sleeping')

ORDER BY

    r.start_time DESC;

4..Script to Grant Permissions to a User:

USE [YourDatabaseName]

GO

GRANT SELECT, INSERT, UPDATE, DELETE ON [YourSchema].[YourTable]

TO [YourUserName];

5.Script to Update Statistics for a Table:

USE [YourDatabaseName]

GO

UPDATE STATISTICS [YourSchema].[YourTable];



CLOUD COMPUTING

 CLOUD COMPUTING 

Cloud computing has revolutionized the way businesses and individuals approach technology infrastructure and services. In today's digital age, where data storage, processing power, and software applications play a critical role in our daily lives, cloud computing offers a flexible and scalable solution. By leveraging remote servers and networks accessed through the internet, cloud computing enables users to store, manage, and access data and applications seamlessly from anywhere in the world. In this blog post, we will explore the fundamental concepts of cloud computing, its benefits, and its impact on various industries, as well as address common misconceptions to help you understand why cloud computing has become an essential component of modern-day technology strategies."



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;

    ';




The Impact of COVID-19: Layoffs in the IT Field 2020



COVID-19 has negatively impacted almost all careers, and software engineering is no exception. However, a survey conducted by 
Career Explorer suggests that software engineers are faring better than other professionals. Among surveyed professionals across all industries and job titles, 20% of respondents have reported losing a job due to COVID-19.
Among the survey respondents, software engineers experienced a 5% job loss. Also, 48% of all the surveyed professionals showed concern about job security. On the other hand, only 31% of software engineers highlighted the issue of job security.
It is important to highlight here that the above software engineering job respondent data is taken from across the industrial spectrum. Engineers and developers working in different sectors may likely face contrasting situations. For instance, software engineers and developers working in the hospitality industry have to experience pay cuts and layoffs.

On the other hand, engineers and developers working on the security side have experienced growth. Their services and products have been in more demand in the last couple of months as workspaces worldwide have become more dependent on technology. In the US alone, the demand for cybersecurity professionals has surged by 65% since April

SQL SERVER 2012,2014,2016,2017 New Features

Each version introduced its own set of new features and enhancements. Here are some notable new features introduced in SQL Server 2012 and SQL Server 2014: 

------SQL Server 2012------

AlwaysOn Availability Groups: This feature provides high availability and disaster recovery solutions by allowing multiple databases to be grouped together and failover as a single unit.

Columnstore Indexes: SQL Server 2012 introduced columnstore indexes, which significantly improve query performance for data warehousing and analytics workloads by storing data in a columnar format.

SQL Server Data Tools (SSDT): SSDT provides an integrated development environment for database developers, offering enhanced database design, testing, and deployment capabilities.

SQL Server Analysis Services (SSAS) Tabular Model: In addition to the traditional multidimensional model, SQL Server 2012 introduced the tabular model for SSAS, which provides a simpler, in-memory approach for building analytical solutions.

------SQL Server 2014--------

In-Memory OLTP:: This feature, also known as Hekaton, allows you to store selected tables and procedures in memory, resulting in significantly improved performance for transactional workloads.

Buffer Pool Extension: SQL Server 2014 introduced the ability to extend the buffer pool into solid-state drives (SSDs), enabling faster access to frequently accessed data and reducing I/O latency.

Enhanced Backup and Restore: SQL Server 2014 introduced backup encryption, making it easier to secure sensitive data during backups. It also provided the ability to perform a database restore from Windows Azure storage, allowing for off-site backups and disaster recovery.

Delayed Durability : This feature allows you to control the durability of transaction commits, improving performance for write-intensive workloads.

Both versions brought new features and improvements to the SQL Server platform. Here are some notable features introduced in SQL Server 2016 and SQL Server 2017:

---SQL Server 2016-----




Stretch Database: This feature allows you to transparently and securely extend your on-premises database to Azure SQL Database, providing cost-effective storage and seamless access to historical data.

Query Store: Query Store provides detailed insights into query performance by capturing query execution plans and statistics, enabling easy identification and resolution of performance regressions.

PolyBase: PolyBase enables you to query and analyze data across relational and non-relational data sources, such as Hadoop, using T-SQL, making it easier to integrate and process big data alongside traditional SQL Server data.

JSON Support: SQL Server 2016 introduced built-in support for storing, querying, and manipulating JSON data, allowing for better integration with modern application development and data interchange formats.

-----SQL Server 2017------


Graph Database Capabilities: SQL Server 2017 introduced support for graph database features, enabling the modeling and querying of complex relationships between data entities, making it suitable for scenarios such as social networks and fraud detection.

Automatic Tuning: This feature leverages machine learning to continuously monitor and optimize query performance by automatically applying performance recommendations, including creating indexes or adjusting query plans.

Resumable Online Index Rebuild: SQL Server 2017 introduced the ability to pause and resume index rebuilding operations, allowing for more flexibility and reduced maintenance windows for large-scale index maintenance.

Adaptive Query Processing: This feature provides intelligent query performance optimization by dynamically adjusting execution plans based on actual runtime statistics, leading to more efficient query processing.


    Essential SQL Queries for Database Administrators (DBAs)"

    select * from sys.dm_db_session_space_usage: 

    This query can be used to monitor the space usage of each session in the database, helping you identify any sessions that are consuming excessive space.

    dbcc sqlperf(logspace): 

    By executing this command, you can obtain information about the transaction log space usage for each database. It helps you identify if any transaction logs are growing too large and may require management.

    xp_fixeddrives: 

    This query provides information about the fixed drives (hard drives) on the SQL Server machine. As a DBA, you can use this to ensure sufficient disk space is available for the database files and logs.

    dbcc showcontig:

     Use this command to analyze the fragmentation level of tables and indexes. It helps you identify fragmented objects that might impact performance and allows you to plan for defragmentation or index maintenance.

    select * from sys.dm_db_index_physical_stats: 

    This query returns detailed physical statistics about indexes in a specified table or view. It helps you analyze index fragmentation, identify unused indexes, and optimize the indexing strategy.

    select * from sys.dm_exec_requests order by cpu_time: 

    By running this query, you can monitor the CPU time consumed by different SQL requests, helping you identify resource-intensive queries that may require optimization.

    select * from sys.dm_exec_sessions:

     This query provides information about active sessions on the SQL Server instance. It allows you to monitor the current connections, identify long-running sessions, and troubleshoot blocking issues.

    select * from sys.dm_os_waiting_tasks where session_id > 0:

     Use this query to identify the waiting tasks on the SQL Server instance for user sessions. It helps you investigate and resolve blocking and contention issues.

    select * from sys.dm_os_wait_stats: 

    This query retrieves wait statistics at the system level, allowing you to identify the most common waits and potential bottlenecks in the system.

    select * from sys.dm_io_virtual_file_stats: 

    By executing this query, you can monitor the I/O statistics for database files, helping you identify any performance issues related to disk I/O.

    select * from sys.dm_os_performance_counters: 

    This query retrieves performance counter information for the SQL Server instance. It enables you to monitor various server performance metrics such as CPU usage, memory utilization, and disk activity.




     

    Upgrade to SQL Server 2016 Using the Installation Wizard (Setup)

     Upgrade to SQL Server 2016 Using the Installation Wizard (Setup)

    Reasons for Upgradation

            --New features of SQL Server version

            --MS stop support

            --When the application or front-end part was updated

            --When integrating with other RDBMS products...

     Upgradation Types

            --In-Place

            --Side-by-Side

     In-Place Upgradation Restrictions

    1. Patching is required on existing instance

                               2012      2014

           2005             SP4        SP4

           2008             SP2        SP3

           2008R2        SP1        SP2

           2012                           SP1

    2. We can upgrade from previous two versions.

                  9.0                10.0,10.5, 11.0,12.0

    3. All components must be upgraded

    4. Architecture must be same (32 to 32 or 64 to 64)

    5. Editions must same or higher

    Before upgrade

    MSSQL11.LIC             (8 FOLDERS)

     After Upgrade

    MSSQL11.LIC             (6 FOLDERS)

    MSSQL12.LIC            (2 FOLDERS) Binn, Install

    The SQL Server Installation Wizard provides a single feature tree for an in-place upgrade of SQL Server components to SQL Server 2016.

    Warning

    When you upgrade SQL Server, the previous SQL Server instance will be overwritten and will no longer exist on your computer. Before upgrading, back up SQL Server databases and other objects associated with the previous SQL Server instance.

    Caution

    For many production and some development environments, a new installation upgrade or a rolling upgrade is more appropriate than an in-place upgrade. For more information regarding upgrade methods, see Choose a Database Engine Upgrade MethodUpgrade Data Quality ServicesUpgrade Integration ServicesUpgrade Master Data ServicesUpgrade and Migrate Reporting ServicesUpgrade Analysis Services andUpgrade Power Pivot for SharePoint.


    Warning

    Be aware that you cannot change the features to be upgraded, and you cannot add features during the upgrade operation. For more information about how to add features to an upgraded instance of SQL Server 2016 after the upgrade operation is complete, see Add Features to an Instance of SQL Server 2016 (Setup).

    • Back up all SQL Server database files from the instance to be upgraded, so that you can restore them, if it is required.
    • Run the appropriate Database Console Commands (DBCC) on databases to be upgraded to ensure that they are in a consistent state.
    • Ensure that existing SQL Server system databases - master, model, msdb, and tempdb - are configured to autogrow, and ensure that they have sufficient hard disk space.
    • Ensure that all database servers have logon information in the master database. This is important for restoring a database, as system logon information resides in master.
    • Disable all startup stored procedures, as the upgrade process will stop and start services on the SQL Server instance being upgraded. Stored procedures processed at startup time might block the upgrade process.
    • When upgrading instances of SQL Server where SQL Server Agent is enlisted in MSX/TSX relationships, upgrade target servers before you upgrade master servers. If you upgrade master servers before target servers, SQL Server Agent will not be able to connect to master instances of SQL Server.
    • Quit all applications, including all services that have SQL Server dependencies. Upgrade might fail if local applications are connected to the instance being upgraded.
    • Make sure that Replication is current and then stop Replication. For detailed steps for performing a rolling upgrade in a replicated environment, 

    Note:

    If you have opted to upgrade the shared features by selecting <Upgrade shared features only> on the Select Instance page, all the shared features are preselected on the Feature Selection page. All the shared components are upgraded at the same time.

    12.   On the Instance Configuration page, specify the Instance ID for the instance of SQL Server.
    Instance ID — By default, the instance name is used as the Instance ID. This is used to identify installation directories and registry keys for your instance of SQL Server. This is the case for default instances and named instances. For a default instance, the instance name and instance ID would be MSSQLSERVER. To use a non-default instance ID, provide a value for the Instance ID textbox.
    All SQL Server service packs and upgrades will apply to every component of an instance of SQL Server.
    Installed instances — The grid will show instances of SQL Server that are on the computer where Setup is running. If a default instance is already installed on the computer, you must install a named instance of SQL Server 2016.
    13.   Work flow for the rest of this topic depends on the features that you have specified for your installation. You might not see all the pages, depending on your selections.
    14.   On the Server Configuration — Service Accounts page, the default service accounts are displayed for SQL Server services. The actual services that are configured on this page depend on the features that you are upgrading.
    Authentication and login information will be carried forward from the previous instance of SQL Server. You can assign the same login account to all SQL Server services, or you can configure each service account individually. You can also specify whether services start automatically, are started manually, or are disabled. Microsoft recommends that you configure service accounts individually so that SQL Server services are granted the minimum permissions they have to have to complete their tasks. For more information, see Configure Windows Service Accounts and Permissions.
    To specify the same login account for all service accounts in this instance of SQL Server, provide credentials in the fields at the bottom of the page.
    Security Note Do not use a blank password. Use a strong password.
    When you are finished specifying login information for SQL Server services, clickNext.
    15.   On the Full-Text Search Upgrade Options page, specify the upgrade options for the databases being upgraded. For more information, see Full-Text Search Upgrade Options.
    16.   The Feature Rules window will automatically advance if all rules pass.
    17.   The Ready to Upgrade page displays a tree view of installation options that were specified during Setup. To continue, click Install. SQL Server Setup will first install the required prerequisites for the selected features followed by the feature installation.
    18.   During installation, the progress page provides status so that you can monitor installation progress as Setup continues.
    19.   After installation, the Complete page provides a link to the summary log file for the installation and other important notes. To complete the SQL Server installation process, click Close.
    20.   If you are instructed to restart the computer, do so now. It is important to read the message from the Installation Wizard when you have finished with Setup. For more information about Setup log files, see View and Read SQL Server Setup Log Files.


    • Register your servers — Upgrade removes registry settings for the previous instance of SQL Server. After you upgrade, you must reregister your servers.
    • Update statistics — To help optimize query performance, we recommend that you update statistics on all databases following upgrade. Use the sp_updatestats stored procedure to update statistics in user-defined tables in SQL Server databases.
    • Configure your new SQL Server installation — To reduce the attackable surface area of a system, SQL Server selectively installs and enables key services and features. For more information about surface area configuration, see the readme file for this release.
    • Change database compatibility Levels
    • Apply latest SP of new version
    • Run all maintenance Plan Tasks
    • Take Full backup of databases
    • Verify latest version /compatible version of SQL Native Client is there in the appl/webserver
    • Check the connectivity from applications

    Prerequisites

    You must run Setup as an administrator. If you install SQL Server from a remote share, you must use a domain account that has read and execute permissions on the remote share, and is a local administrator.

    If you are upgrading the Database Engine, review Plan and Test the Database Engine Upgrade Plan and then perform the following tasks, as appropriate for your environment:

    Procedure

    To upgrade to SQL Server 2016:


    1.   Insert the SQL Server installation media, and from the root folder, double-click Setup.exe. To install from a network share, move to the root folder on the share, and then double-click Setup.exe.

    2.   The Installation Wizard starts the SQL Server Installation Center. To upgrade an existing instance of SQL Server, click Installation in the left-hand navigation area, and then click Upgrade from SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, or SQL Server 2014.

    3.   On the Product Key page, click an option to indicate whether you are upgrading to a free edition of SQL Server, or whether you have a PID key for a production version of the product. For more information, see Editions and Components of SQL Server 2016 and Supported Version and Edition Upgrades.

    4.   On the License Terms page, review the license agreement and, if you agree, select the I accept the license terms check box, and then click Next. To help improve SQL Server, you can also enable the feature usage option and send reports to Microsoft.

    5.   In the Global Rules window, the setup procedure will automatically advance to the Product Updates window if there are no rule errors.

    6.   The Microsoft Update page will appear next if the Microsoft Update check box in Control Panel\All Control Panel Items\Windows Update\Change settings is not checked. Putting a check in the Microsoft Update page will change the computer settings to include the latest updates when you scan for Windows Update.

    7.   On the Product Updates page, the latest available SQL Server product updates are displayed. If you don't want to include the updates, clear the Include SQL Server product updates check box. If no product updates are discovered, SQL Server Setup does not display this page and auto advances to the Install Setup Filespage.

    8.   On the Install Setup Files page, Setup provides the progress of downloading, extracting, and installing the Setup files. If an update for SQL Server Setup is found, and is specified to be included, that update will also be installed.

    9.   In the Upgrade Rules window, the setup procedure will automatically advance to the Select instance window if there are no rule errors.

    10.                On the Select Instance page, specify the instance of SQL Server to upgrade. To upgrade Management tools and shared features, select Upgrade shared features only.

    11.                On the Select Features page, the features to upgrade will be preselected. A description for each component group appears in the right pane after you select the feature name.

    The prerequisites for the selected features are displayed on the right-hand pane. SQL Server Setup will install the prerequisite that are not already installed during the installation step described later in this procedure.

    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...