Open links in new tab
  1. SQL Server Management Studio (SSMS) allows you to run T-SQL queries for retrieving, inserting, updating, and deleting data. Below are practical examples using the AdventureWorks sample database.

    Basic SELECT Queries Retrieve all columns:

    USE AdventureWorks2022;
    SELECT *
    FROM Production.Product
    ORDER BY Name ASC;
    Copied!

    Retrieve specific columns with alias:

    SELECT Name, ProductNumber, ListPrice AS Price
    FROM Production.Product
    WHERE ProductLine = 'R' AND DaysToManufacture < 4
    ORDER BY Name ASC;
    Copied!

    Aggregations and GROUP BY Summarize sales per order:

    SELECT SalesOrderID, SUM(LineTotal) AS SubTotal
    FROM Sales.SalesOrderDetail
    GROUP BY SalesOrderID
    ORDER BY SalesOrderID;
    Copied!

    Filter groups with HAVING:

    SELECT ProductID, AVG(OrderQty) AS AvgQty
    FROM Sales.SalesOrderDetail
    GROUP BY ProductID
    HAVING AVG(OrderQty) > 5;
    Copied!

    JOIN Examples Inner join to combine employee and person data:

    SELECT E.NationalIDNumber, E.JobTitle, P.FirstName, P.LastName
    FROM HumanResources.Employee AS E
    INNER JOIN Person.Person AS P
    ON E.BusinessEntityID = P.BusinessEntityID;
    Copied!
  1. SELECT Examples (Transact-SQL) - SQL Server | Microsoft Learn

    Feb 2, 2026 · This article provides examples of using the SELECT statement. The code samples in this article use the AdventureWorks2025 or AdventureWorksDW2025 sample database, which you can …

  2. SQL Query Examples - SQL Server Tips

    • The select statement is the most basic and simple SQL to query data. Here is the basic syntax: The following example will query the information from the Person.Person table from the Adventurework2019 database. The following SQL will query all the columns from the table, by using * instead of specifying column names. You could also use the following...
    See more on mssqltips.com
    • Published: Feb 23, 2022
    • SQL Server Tutorial

      The SQL Server Tutorial website offers practical tutorials with many hands-on examples to help you learn SQL Server quickly and effectively.

    • 15 SQL Server Practice Exercises with Solutions

      May 28, 2024 · Explore 15 SQL Server exercises for beginners, each with a solution and explanation to boost your T-SQL querying skills

    • T-SQL by Example — T-SQL by Example

      T-SQL by Example Welcome to T‑SQL by Example. Each page shows a bite‑sized example with runnable code, output (when helpful), and a few notes & gotchas. Start with Basics, then explore Joins, …

    • T-SQL Examples - Quackit Tutorials

      Transact-SQL (T-SQL) is Microsoft's extension to SQL. Here are examples of some of the more common T-SQL statements. Selects all data from the Artists table. This is the most basic example of a SELECT …

    • SQL Queries in SQL Server – a beginner’s guide

      Learn how to create SQL queries in SQL Server using the SELECT, WHERE, GROUP BY, JOIN and other clauses. See examples of queries with the AdventureWorks …

    • SQL Server Basics

      The SQL server basics section shows you how to use the Transact-SQL (T-SQL) statements to interact with SQL Server databases.

    • SQL Server Examples

      This article provides a collection of SQL Server examples that cover a variety of tasks, from basic data retrieval to complex data manipulation. The examples are written in T-SQL, the standard language for …

    • Sample Queries - fmsasg.com

      The following query should be used with extreme caution and only by a SQL programmer experienced with similar tasks. This query imports data directly into the Sentinel Visualizer database, bypassing …

    • People also ask
      Loading
      Unable to load answer