How to update select t-sql

Written by alexander gokhfeld
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to update select t-sql
T-SQL UPDATE and SELECT statements update data in SQL databases. (Ablestock.com/AbleStock.com/Getty Images)

All user applications request data from the SQL databases by sending Transact-SQL (T-SQL) statements to the SQL server, including SELECT and UPDATE T-SQL statements. The UPDATE statement changes the existing SQL Server data in one or more columns of a database table or a database view. The SELECT statement gives users the ability to limit a set of records used in database operations. By using the T-SQL SELECT statement inside of an UPDATE statement you can fulfil a conditional user query on a SQL database.

Skill level:
Easy

Other People Are Reading

Instructions

  1. 1

    Click "Start" in Windows and then click "Microsoft SQL Management Console."

  2. 2

    Enter the following T-SQL code in the open window:

    UPDATE titles

    SET ytd_sales =

      (SELECT SUM(qty)
    
         FROM sales
    
            WHERE sales.title_id = titles.title_id
    
            AND sales.ord_date IN (SELECT MAX(ord_date) FROM sales))
    

    FROM titles, sales

  3. 3

    Click "File' and then click "Save" to update sales data within the selected date range.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.