Month: November 2023

  • Performing Subtotal Calculations with ROLLUP in SQL

    Performing Subtotal Calculations with ROLLUP in SQL

    In SQL, the ROLLUP operator allows us to generate subtotal calculations in our query results. Subtotals can provide valuable insights by summarizing data at different levels of granularity. This article explores how to use the ROLLUP operator to perform subtotal calculations in SQL, specifically focusing on generating a “Total” label for the “product” column. The…

    Continue reading

  • Understanding Pivot in MSSQL

    Understanding Pivot in MSSQL

    Pivot is a powerful feature in Microsoft SQL Server (MSSQL) that allows you to transform rows into columns, providing a convenient way to summarize and analyze data. In this article, we will explore the usage of the pivot operator in MSSQL and understand how it can be applied to reshape data.

    Continue reading

  • How to List All Triggers in a MSSQL Database

    How to List All Triggers in a MSSQL Database

    In MSSQL, triggers are special types of stored procedures that are automatically executed in response to specific events, such as data manipulation operations on tables. Triggers can be useful for enforcing business rules, auditing changes, or performing additional actions when certain conditions are met. If you want to list all triggers in a specific database,…

    Continue reading

  • Understanding the Differences Between IDENTITY, SCOPE_IDENTITY(), and IDENT_CURRENT() in MSSQL

    Understanding the Differences Between IDENTITY, SCOPE_IDENTITY(), and IDENT_CURRENT() in MSSQL

    In SQL Server databases, there are three important functions used to retrieve values associated with auto-increment fields: IDENTITY, SCOPE_IDENTITY(), and IDENT_CURRENT(). Although they serve a similar purpose, these functions have distinct characteristics and use cases. This article aims to explore the differences between them and provide a clear understanding of their individual functionalities. The IDENTITY…

    Continue reading

  • How to List Table Sizes in MSSQL

    How to List Table Sizes in MSSQL

    Using SQL Server Management Studio (SSMS): You can use SQL Server Management Studio (SSMS) to list the size of tables. Follow the steps below: Using this method, you can manually check the size of each table. Using T-SQL Query: You can list the size of tables in KB and MB using the following T-SQL query:…

    Continue reading