Using T-SQL to Modify Tables

You can modify tables in many different ways, including making changes to the columns, constraints, and indexes associated with a table. Some of the changes have a bigger impact on the database than others. Some modifications require that the modified table be dropped and re-created to effect the change. Fortunately, you can use the T-SQL ALTER TABLE statement to mitigate the database impact and help streamline many of the most common modifications. You can make the following types of changes by using the ALTER TABLE statement:

• Change a column property, such as a data type or NULL property.

• Add new columns or drop existing columns.

• Add or drop constraints.

• Enable or disable CHECK and FOREIGN KEY constraints. ...

Get Microsoft® SQL Server 2008 R2 Unleashed 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.