Day 7

Quiz

1:What is wrong with the following statement?
DELETE * FROM customer_demo
A1: This statement should not be using the '*'. In addition, the FROM keyword is optional. The correct syntax of this statement is
DELETE FROM customer_demo

Or

DELETE customer_demo

Remember that this would delete all the data in the table.

2:What is wrong with the following statement?
UPDATE customer_demo (
    'John', 'smith', 34)
A2: Answer: This statement mixes the UPDATE command with the INSERT command. To UPDATE values into the customer_demo table, you use the following syntax for an update:
UPDATE customer_demoSET Fname = 'John',
    Lname = 'smith'
    age = 34

And for an insert, the following syntax would be used:

 INSERT INTO customer_demo (Fname, Lname, Age) Values('John', ...

Get Sams Teach Yourself Transact-SQL in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.