SQL Transact UPDATE Statement
One you have mastered SELECT, its time to turn your attention to SQL’s UPDATE statements.
Lesson 1 – UPDATE .. SET
The scenario: You prices must rise! You need to increase prices in line with inflation, you have held down the price for two years, but now is the time for a 5% rise
Let us find carry out a preliminary investigation.
Note 1: Check you are using the pleural productS, as the name of this table.
Note 2: This is standard practice to run a SELECT before the UPDATE.
Before and after.
Make a physical, or mental note of the Aniseed Syrup 10.00?
UPDATE…. SET statement
Note 1: Update needs the SET counterpart.
Note 2: Check the syntax, particularly the brackets,
Note 3: By using GO, we executed two statements in one session.
After the event check
How much was the Aniseed Syrup after the price increase?
Guy’s Out Takes
You may like tobackup Northwind before tackling the UPDATE statement. Certainly you should backup in the ‘real world’ before a batch update of rows.
SQL Transact Out Take
What is the problem with this SQL statement?
Answer: Wrong type of speech marks it should only be a single quote mark
‘Aniseed Syrup’; SQL transect doe not support double quotes in WHERE clauses, "Aniseed Syrup" would be incorrect.