Introduction to Advanced Queries
In the last module, you learned how to select data, which is a very important step in learning how to use SQL Server.
In this module, we are going to build upon this knowledge by using queries to insert, update, and delete data.
After completing this module, you will be able to:
- Use literal values in your
UPDATE queries to modify a table using values from another table
DELETE statements using subqueries
- Optimize your
In the next lesson, you will get an overview of the
statement, which is used to insert data into your tables.
Rules and constraints provide restriction information about what can go into a table. If an updated or inserted record violates a rule, that insertion or update will be rejected. In addition, a rule can be
used to defi ne a restriction on a user-defi ned data type. Unlike constraints, rules are not bound to a particular table. Instead they are independent objects that can be bound to multiple tables or even to
specifi c data types (which are, in turn, used in tables).
Rules have been considered deprecated by Microsoft for several releases now. They should be considered
for backward compatibility only, and you should avoid them in new development.
There are two types of defaults.
- There is the default that is an object unto itself, and
- the default that is not really an object, but rather metadata describing a particular column in a table (in much the same way that there are rules, which are objects, and constraints,
which are not objects, but metadata).
They serve the same purpose. If, when inserting a record, you do not provide the value of a column and that column has a default defi ned, a value will be inserted automatically as defi ned in the default.