Queries can also be used to update data in a table. In this video, database expert Adam Wilbert shows how to use the UPDATE clause in a SQL Server 2016 T-SQL query to update the values stored in a table. By combining UPDATE with a WHERE clause in the same query, the alterations can be targeted to specific records.
- [Instructor] Using a query,…we can update data that's stored in our data tables.…This will require the use of a new keyword,…that we haven't seen yet, called Update.…First, I wanna review the information,…that's stored inside of our Wide World Importers Database,…inside of the Sales.SpecialDeals table.…I'll Right-click on it, and choose Select Top 1000 Rows.…Now this table only has two records currently.…The first is a discount that applies to orders placed…by a company called Wingtip Toys,…you can see that right over here.…And it's for a discount of 10%,…that I'll apply during the first quarter of 2016.…We can see that we have StartDate and EndDate columns,…that confirm that it'll begin on the 1st of January,…and end on the 31st of March.…
Now let's suppose, that the discount has been re-negotiated,…and should continue to apply until the end of the year.…We'll need to update the values in the EndDate column,…and the DealDescription column,…but we only want the update to occur for this first record,…with the SpecialDealID number one.…
This course introduces the most important features of SQL Server 2016, and is designed to act as the student's very first look at how the server operates. Adam Wilbert shows how to install a local copy of SQL Server; demonstrates the working environment, SQL Server Management Studio; and walks students through their first hour creating tables, defining relationships, and writing and running queries with Transact-SQL commands. Everything you need to accomplish to create your first database is covered in just 80 minutes. Start watching to get up and running with this professional-grade database management system.
- What is SQL Server?
- Configuring the server
- Creating a new database and data tables
- Joining tables with keys
- Creating a SELECT statement
- Writing an UPDATE statement
- Adding data with the INSERT statement