346 Part I EXAM PREPARATION later in Chapter
346 Part I EXAM PREPARATION later in Chapter 9 when you learn about user-defined functions and stored procedures. For now, you need to know what a RETURN does within a statement block. You can use it like this: BEGIN UPDATE mytable SET emptype = manager WHERE name = . fred RETURN UPDATE mytable SET name = george WHERE id = 42 END If you do that, the second UPDATE never runs. Not very useful now, but when you read through the next section on IF…THEN…ELSE, you ll understand. CONDITIONAL STATEMENTS AND BRANCHING WITH IF…THEN…ELSE So far, all the scripts you ve seen start at the top and go to the bottom. There s no way of conditionally executing any statements; all the statements execute, top down. That s not good. So SQL Server provides you with a couple of different ways to do something just in case something else is true. So, you want to actually write a batch that does something now? Need to insert a piece of data, but don t want to insert a duplicate? How about wanting to make sure that the data you re about to insert follows the rules for that type of data? Well, now you need to understand conditional execution and the IF…ELSE construct. In T-SQL, an IF statement looks like this: IF
For high quality website hosting services please check java web hosting website.