3_Basic-DML-Statements-and-Operator
3_Basic-DML-Statements-and-Operator
Fsoft Academy
Describe each dataThis is a sample text that you can edit. You can
manipulation language (DML) statement
01 change font(size, color, name), or apply any
desired formatting.
1. DML Statements
2. SQL Operators
DML Statements
▪ Best Practice
✓ Use the @@ROWCOUNT function to return the number of inserted rows to the client
application.
09e-BM/DT/FSOFT - @FPT SOFTWARE - FPT Software Academy - Internal Use 9
UPDATE Statement
▪ Syntax:
UPDATE table_name
SET column1=value1,column2=value2,...
WHERE some_column=some_value;
The WHERE clause specifies which record or records that should be updated. If you omit the WHERE clause,
all records will be updated!
▪ Code:
USE Fsoft_Training
UPDATE dbo.Customer
SET PostalCode = '4006' WHERE Country = 'Norway‘
Please note that the DELETE FROM command cannot delete any rows of data that would violate
FOREIGN KEY or other constraints.
Tips: The SELECT INTO statement can also be used to create a new, empty table using the
schema of another. Just add a WHERE clause that causes the query to return no data:
SELECT *
INTO newtable
FROM table1 WHERE 1=0;
SQL Operators
3 Logical operators.
https://learn.microsoft.com/en-us/sql/t-sql/language-elements/operators-transact-sql?view=sql-server-ver16
CUSTOMERS TABLE
• Find the top 5 people in the Contact table who have a first name that starts with Al and has a
third letter that is not the letter a.