Chapter 16. Modifying Data

In This Chapter

  • Inserting data from expressions, other result sets, and stored procedures

  • Updating data

  • Deleting data

  • Avoiding and solving complex data-modification problems

Things change. Life moves on. Because the purpose of a database is to accurately represent reality, the data must change along with reality. For SQL programmers, that means inserting, updating, and deleting rows—using the basic Data Manipulation Language (DML) commands. However, these operations aren't limited to writing single rows of data. Working with SQL means thinking in terms of data sets. The process of modifying data with SQL draws upon the entire range of SQL Server data-retrieval capabilities—the powerful select, joins, full-text searches, subqueries, and views.

Note

The SQL insert, update, and delete commands are really verb extensions of the basic select command. The full potential of the select command lies within each data-modification operation. Even when modifying data, you should think in terms of sets, rather than single rows.

This chapter is all about modifying data within SQL Server using the insert, update, and delete SQL commands. Modifying data raises issues that need to be addressed, or at least considered. Inserting primary keys requires special methods. Table constraints may interfere with the data modification. Referential integrity demands that some delete operations cascade to other related tables. This chapter will help you understand these concerns and offer ...

Get SQL Server™ 2005 Bible 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.