Q&A

Q1:Can I copy data from a table into itself using the INSERT command? In addition, I want to change the value of one column.
A1: By using the INSERT statement with a SELECT statement, you can copy all the rows from the table into itself. However, you must modify the column in question as a separate step. You cannot update columns while performing this type of INSERT. The following code shows how to perform these tasks:
Insert customer_demo
Select * from customer_demo
Update customer_demo
Set Addr2 = 'unavailable'
Q2:You said that caution should be taken when using the INSERT, UPDATE, DELETE statements, but there seem to be some simple fixes to correct whatever I did wrong. Is this correct?
A2: Yes. For example, a simple way to fix a misspelled ...

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.