Figure 4   SQL Comparison Operators

< less than
<= less than or equal
= equal
> greater than
>= greater than or equal
<> different from


Figure 5   Select Case Construct

SELECT AGE = 
    CASE
        Year IS NULL THEN 'Undetermined'
        Year < '01/01/1970' THEN 'Ancient'
        Year BETWEEN '01/01/1970' AND '01/01/1985' THEN 'Modern'
        Year BETWEEN '01/01/1985' AND '01/01/1999' THEN 'Contemporary'
        ELSE 'Not yet published'
    END,
YEAR, NAME, AUTHOR, BOOKTYPE = 
    CASE TYPE
        WHEN 0 THEN 'FICTION'
        WHEN 1 THEN 'NON-FICTION'
    END
FROM BOOKS

Figure 6   Cursor Declaration Syntax

A cursor is declared using the following syntax:

DECLARE cursor-name [SCROLL] [INSENSITIVE] CURSOR
FOR select-statement
[FOR {READ ONLY | UPDATE [OF column-list]]
where:

cursor-name Is the name of the cursor.
SCROLL Indicates that access to the cursor should be random. If SCROLL is not specified, the cursor can only be accessed one row at a time in a forward-only direction.
INSENSITIVE Forces MSSQL to create a copy of the information extracted by select-statement in a temporary table and return it from there. A cursor created using this keyword can only be read-only and will be unaffected by external changes (such as deletion of records by another query).
select-statement
Specifies a valid SQL select statement from which the result rowset will be taken.
FOR READ ONLY
Opens the cursor as read-only. No row updates are allowed.
FOR UPDATE Specifies that the rows extracted by the cursor are updateable. Incompatible with FOR READ ONLY.
column-list Indicates a list of specific rows that can be modified.