IT452 Unit 7 Programmable Objects
1. Create a variable for the region column, birthdate column and empid column.
2. Create and use a variable to pull the category name for categoryID 8. Write a separate query to return the output.
3. Write an IF ELSE element that checks for the current month and prints ‘This Month is November’ if it is November or prints ‘This Month is not November’ if the month is not November.
Prints This Month is November if you enter 11
4. Write a WHILE Loop that returns ProductName, CategoryID and UnitPrice and compares the CategoryID to 4. As long as it is less than 4 it should print the product name, categoryid and unitprice.
12 rows for Category 1
12 rows for Category 2
13 rows for Category 3
5. Write a script that performs the following tasks:
a. Define a variable to hold the maximum database ID value.
b. Set that variable equal to the maximum database ID value. To determine the maximum database ID value, use the database_id column of the sys.databases table in the master database.
c. Use PRINT to print the value of the variable. Result: [Note: PRINT writes to the Messages tab of the query window.]
[Note: Your result may vary.]
6. Create a cursor that updates only to and from the ProductName column of the Production.Products table and print that column out. Returns all of the productnames upon successful execution
7. Create a table variable called work table with the following structure. Insert the row of data listed and execute the batch.
PK int Primary Key
Col1 int Not Null
Insert 1 row with the following data:
Execute the batch
Returns 1 row
8. Create a global temporary table called GlobalTempWork with the following structure
Test nvarchar primary key,
Insert 1 row with the following data
Execute the batch to return the 1 row