0% found this document useful (0 votes)
67 views

T-SQL Enhancements

This exercise teaches how to use the PIVOT and UNPIVOT operators in SQL Server 2005. The tasks include: 1. Creating tables to store sample sales data categorized by month and year. 2. Using the PIVOT operator to transform the data from rows to columns, displaying customer sales totals by month or year. 3. Comparing the results of the PIVOT queries to the original data to see how the operator changes the data layout. The goal is to learn how to restructure relational data for easier analysis and reporting using these new operators.

Uploaded by

Vilus Vili
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views

T-SQL Enhancements

This exercise teaches how to use the PIVOT and UNPIVOT operators in SQL Server 2005. The tasks include: 1. Creating tables to store sample sales data categorized by month and year. 2. Using the PIVOT operator to transform the data from rows to columns, displaying customer sales totals by month or year. 3. Comparing the results of the PIVOT queries to the original data to see how the operator changes the data layout. The goal is to learn how to restructure relational data for easier analysis and reporting using these new operators.

Uploaded by

Vilus Vili
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 18

T-SQL Enhancements

Table of Contents

SQL Server 2005: T-SQL Enhancements...................................................................................................................3


Lab Setup........................................................................................................................................................................4
Exercise 1 PIVOT and UNPIVOT Operators.................................................................................................................5
Exercise 2 Common Table Expressions and Recursive Queries....................................................................................9
Exercise 3 DDL Triggers and EventData()...................................................................................................................13
Exercise 4 Event Handling............................................................................................................................................16
T-SQL Enhancements

T-SQL Enhancements
In this lab, you will familiarize your self with the new and enhanced
Objectives features of T-SQL.
After completing this lab, you will be able to:
NOTE: This lab focuses on the
concepts in this module and as a  Use the new PIVOT and UNPIVOT operators
result may not comply with  Use Recursive Query Expressions
Microsoft security
recommendations.
 Create triggers that are invoked by Data Definition Language
(DDL) events
NOTE: The SQL Server 2005 labs  Handle Exceptions in T-SQL
are based on beta builds of the
product. The intent of these labs is
to provide you with a general feel of
some of the planned features for
the next release of SQL Server. As
with all software development
projects, the final version may differ
from beta builds in both features
and user interface. For the latest
details on SQL Server 2005, please
visit
http://www.microsoft.com/sql/2005/.
Many enhancements have been made to T-SQL and this lab will
Scenario provide exercises to help you understand how these enhancements
work and how you may leverage them in your environment. The lab
exercises will cover usage of new data types, recursive query
expressions, triggers, exception handling and the new
PIVOT/UNPIVOT operators.
 Prior basic working experience with SQL Server 7.0 or SQL
Prerequisites Server 2000
 Familiarity with T-SQL
 Familiarity with SQL Server Management Studio or completion
of the lab on SQL Server Management Studio
60 Minutes
Estimated Time to Complete
This Lab

Page 3 of 18
T-SQL Enhancements

Lab Setup
Tasks Detailed Steps
1. Log in. 1. Log in using the Administrator user account. The password is Pass@word1.

Page 4 of 18
T-SQL Enhancements

Exercise 1
PIVOT and UNPIVOT Operators
Scenario
It is often useful to view relational data in multiple dimensions. For some time now, SQL Server has supported the
CUBE and ROLLUP operators. These operators allow data to be viewed in different dimensions and allow
aggregations to be displayed along those dimensions.

The 2005 release of SQL Server introduces support for the PIVOT and UNPIVOT operators. These operators are
less complex to understand and implement than CUBE and ROLLUP, while still allowing the flexibility to view
data along different dimensions. For example, with the PIVOT operator it is almost effortless to rotate rows into
columns to look at Product data along different dimensions such as supplier, current inventory, and amounts.
In this exercise, you will learn how to use the PIVOT and UNPIVOT operators, apply them in several queries, and
compare their output.

Tasks Detailed Steps


1. Create a Management 1. From the Windows task bar, select Start | All Programs | Microsoft SQL
Studio Project. Server 2005 CTP | SQL Server Management Studio.
NOTE: All of the code for this 2. When the Connect to Server dialog box appears, verify that Server type is set
exercise is contained in the to Database Engine, Server name is set to localhost, and that Windows
script file PIV_UNPIV.sql in Authentication is selected as the authentication method.
the C:\MSLabs\SQL Server 3. Click Connect.
2005\Lab Projects\T-SQL Lab
4. Click File | New | Project.
directory. You can copy and
paste from this file to 5. In the New Project dialog box, click SQL Server Scripts.
complete any portion of the 6. Change the Name of the project to TSQLLab.
exercise. 7. Change the Location to C:\MSLabs\SQL Server 2005\User Projects.
8. Clear the Create directory for Solution checkbox.
9. Click OK to open the project.
2. Connect to the 1. In the Solution Explorer, right-click Queries and then click New Query.
Adventure Works 2. When prompted for connection information, type “localhost” for the server
Database. name, verify that Windows Authentication is selected for the authentication
mode, and click Connect.
3. Under Queries, right-click the new script file and click Rename.
4. Rename the script to PIV_UNPIV.sql.
5. Type the following code in the query editor.

USE AdventureWorks
GO

6. Press F5 to execute the statement.


3. Create a table and 1. In the query editor, type the following code to create and populate a table.
populate it with data.
CREATE TABLE SalesOrderTotalsMonthly
(
CustomerID int NOT NULL,
OrderMonth int NOT NULL,
SubTotal money NOT NULL
)
GO

INSERT SalesOrderTotalsMonthly

Page 5 of 18
T-SQL Enhancements

Tasks Detailed Steps


SELECT CustomerID, DATEPART(m, OrderDate), SubTotal
FROM Sales.SalesOrderHeader
WHERE CustomerID IN (1,2,4,6)

To see the capabilities of the PIVOT operator, you are creating a worktable
containing the customer ID, the month an order was taken, and the subtotal due on
the order. This table will be used in subsequent queries.
2. Select the statements you just typed.
3. Press F5 to execute the statements.
4. Create a query that 1. In the query editor, type the following query that will pivot the table so that the
uses the PIVOT sales for each month are output by customer.
operator.
SELECT * FROM SalesOrderTotalsMonthly
PIVOT (SUM(SubTotal) FOR OrderMonth IN
([1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12])) AS a

2. Select the statements you just typed.


3. Press F5 to execute the query.
You should see a row for each customer and columns for each month across the top
of the results. The customer's total order amounts for a given month are displayed.
You can do a simple select on the SalesOrderTotalsMonthly table to compare the
output of the PIVOT results and the original table data.
5. Create a worktable to 1. In the query editor, type the following code to create and populate another
PIVOT results by worktable.
Year.
CREATE TABLE SalesOrderTotalsYearly
(
CustomerID int NOT NULL,
OrderYear int NOT NULL,
SubTotal money NOT NULL
)
GO

INSERT SalesOrderTotalsYearly
SELECT CustomerID, YEAR(OrderDate), SubTotal
FROM Sales.SalesOrderHeader
WHERE CustomerID IN (1,2,4,6,35)

2. Select the statements you just typed.


3. Press F5 to execute the statements.
In this case, you are creating a worktable that contains the sales by year for the
specified customers. You can now use the PIVOT operator to pivot information
based on the year an order was taken.
6. PIVOT results by year 1. In the query editor, type the following queries that will pivot the table so that
and by Customer. each year's sales are output by customer.

SELECT * FROM SalesOrderTotalsYearly


PIVOT (SUM(SubTotal) FOR OrderYear IN ([2002], [2003], [2004])) AS a
GO
SELECT * FROM SalesOrderTotalsYearly
PIVOT (SUM(SubTotal) FOR CustomerID in ([1], [2], [4], [6])) AS a

Page 6 of 18
T-SQL Enhancements

Tasks Detailed Steps


2. Select the queries you just typed.
3. Press F5 to execute the query.
The PIVOT operator is used in two different queries. Each result set is pivoted in a
different direction.
The first result set shows customer orders by year. In this case, each year is shown
as a separate column. Remember that in the original table all years where sales
occurred were stored in a single column.
The second result set shows subtotal amounts so that each customer’s data appears
as a separate column in the result set.
7. Create a worktable to 1. In the query editor, type the following queries that will create a worktable and
store the output from pivot the table so that each year’s sales are output by customer.
prior step’s PIVOT
query.
CREATE TABLE YearlySalesPivot
(
OrderYear int NOT NULL,
[1] money NULL,
[2] money NULL,
[4] money NULL,
[6] money NULL
)
GO

INSERT YearlySalesPivot
SELECT * FROM SalesOrderTotalsYearly
PIVOT (SUM(SubTotal) FOR CustomerID IN ([1], [2], [4], [6])) AS a

2. Select the statements you just typed.


3. Press F5 to execute the statements. If you receive the message, "Warning: Null
value is eliminated by an aggregate or other SET operation," you can safely
ignore it.
8. Compare UNPIVOT 1. In addition to the PIVOT operator, there is an UNPIVOT operator which
and PIVOT results. allows you to normalize pre-pivoted data. To compare the output of these two
operators, you will use the worktable created in the prior step to hold the
pivoted output from a query. This stored output will then be un-pivoted and
compared with the original pivoted results stored in the table.
2. In the Query Editor, type the following queries.

SELECT * FROM YearlySalesPivot


UNPIVOT (SubTotal FOR CustomerID IN ([1], [2], [4], [6])) AS a
ORDER BY CustomerID
-- Displays unpivoted results

SELECT * FROM YearlySalesPivot


-- Displays pivoted results stored in the worktable

3. Select the queries you just typed.


4. Press F5 to execute the query.
9. Drop worktables. 1. In the query editor, type the following code to drop the worktables you created.

DROP TABLE YearlySalesPivot


DROP TABLE SalesOrderTotalsYearly
DROP TABLE SalesOrderTotalsMonthly

Page 7 of 18
T-SQL Enhancements

Tasks Detailed Steps

2. Select the statements you just typed.


3. Press F5 to execute the statements.

Page 8 of 18
T-SQL Enhancements

Exercise 2
Common Table Expressions and Recursive Queries
Scenario
A Common Table Expression (CTE) is a temporary result set derived from a simple query. A CTE can be used in
many of the same ways you use a derived table. CTEs can also contain references to themselves. This allows
database developers to write recursive queries. CTEs can also be used in place of views.

Tasks Detailed Steps


1. Add a new script in 1. Using SQL Server Management Studio, open the TSQLLab project created in
SQL Server the previous exercise, if it's not still open.
Management Studio. 2. Right-click Queries in the Solution Explorer and click New Query.
NOTE: All of the code for this 3. When prompted for connection information, type “localhost” for the server
exercise is contained in the name, verify that the authentication method is set to Windows Authentication,
script file CTE_REC.sql in the and click Connect.
C:\MSLabs\SQL Server 2005\
Lab Projects\T-SQL Lab 4. Right-click the script file and click Rename.
directory. You can copy and 5. Rename the script as CTE_REC.sql
paste from this file to
complete any portion of the
exercise.
2. Use CTE as a Derived 1. In the CTE_REC.sql script, type the following code.
Table.
USE AdventureWorks
GO

WITH SalesCTE(ProductID, SalesOrderID)


AS
(
SELECT ProductID, COUNT(SalesOrderID)
FROM Sales.SalesOrderDetail
GROUP BY ProductID
)
SELECT * FROM SalesCTE
--All Products and the number of times that they
--were ordered

2. Select the statements you just typed.


3. Press F5 to execute the query.

Page 9 of 18
T-SQL Enhancements

Tasks Detailed Steps


3. Filter the CTE used as Just as you might filter the result set returned by a view, you can filter the result set
a Derived Table. contained in a Common Table Expression.
1. In the CTE_REC.sql script, type the following query.

WITH SalesCTE(ProductID, SalesOrderID)


AS
(
SELECT ProductID, COUNT(SalesOrderID)
FROM Sales.SalesOrderDetail
GROUP BY ProductID
)
SELECT * FROM SalesCTE
WHERE SalesOrderID > 50
--All Products that were ordered more than 50 times

2. Select the query you just typed.


3. Press F5 to execute the query.

4. Aggregate the CTEs. 1. In the CTE_REC.sql script, type the following query.

WITH SalesCTE(ProductID, SalesOrderID)


AS
(
SELECT ProductID, COUNT(SalesOrderID)
FROM Sales.SalesOrderDetail
GROUP BY ProductID
)
SELECT AVG(SalesOrderID)
FROM SalesCTE
WHERE SalesOrderID > 50
--Average number of times a Product was ordered
--for all Products that appeared on an order
--more than 50 times

2. Select the query you just typed.


3. Press F5 to execute the query.
Performing aggregations or other computations on the data returned by a Common
Table Expression is similar to doing so for data from a standard table.
5. Use the CTEs The most powerful use of Common Table Expressions is to create recursive queries.
Recursively. Since Common Table Expressions allow references to themselves in the same
query, a recursive query is relatively straightforward to create.
First, create a new table in the database that holds parts and subparts for cars, often
called a bill of materials. Bill of materials tables, organization charts, and other
hierarchical data structures can easily benefit from the use of recursive Common
Table Expressions.
Notice that a given part such as a Body may contain multiple sub parts. For
example, there are 1000 rivets in a body, and each door also contains 100 rivets.
1. Type the following statements in the CTE_REC.sql script.

CREATE TABLE CarParts


(
CarID int NOT NULL,
Part varchar(15),

Page 10 of 18
T-SQL Enhancements

Tasks Detailed Steps


Qty int
)
GO

INSERT CarParts
VALUES (1, 'Body', 'Door', 4)
INSERT CarParts
VALUES (1, 'Body', 'Trunk Lid', 1)
INSERT CarParts
VALUES (1, 'Body', 'Car Hood', 1)
INSERT CarParts
VALUES (1, 'Door', 'Handle', 1)
INSERT CarParts
VALUES (1, 'Door', 'Lock', 1)
INSERT CarParts
VALUES (1, 'Door', 'Window', 1)
INSERT CarParts
VALUES (1, 'Body', 'Rivets', 1000)
INSERT CarParts
VALUES (1, 'Door', 'Rivets', 100)
INSERT CarParts
VALUES (1, 'Door', 'Mirror', 1)

2. Select the statements you just typed.


3. Press F5 to execute the query.
Recursive CTEs are constructed from at least two queries. One is a non-recursive
query, also referred to as the anchor member (AM). The other is the recursive
query, also referred to as the recursive member (RM). These queries are separated
by the UNION ALL operator.
4. In the CTE_REC.sql script, type the following query.

WITH CarPartsCTE(SubPart, Qty)


AS
(
-- Anchor Member (AM):
-- SELECT query that doesn’t refer back to CarPartsCTE
SELECT SubPart, Qty
FROM CarParts
WHERE Part = 'Body'
UNION ALL
-- Recursive Member (RM):
-- SELECT query that refers back to CarPartsCTE
SELECT CarParts.SubPart, CarPartsCTE.Qty * CarParts.Qty
FROM CarPartsCTE
INNER JOIN CarParts ON CarPartsCTE.SubPart = CarParts.Part
WHERE CarParts.CarID = 1
)
-- Outer Query
SELECT SubPart, SUM(Qty) AS q
FROM CarPartsCTE
GROUP BY SubPart

5. Select the query you just typed.


6. Press F5 to execute the query.
The query above lists the total quantities of parts required to create a car body. The
Common Table Expression is initially populated with data from the simple query,

Page 11 of 18
T-SQL Enhancements

Tasks Detailed Steps


“SELECT SubPart, Qty FROM CarParts WHERE Part = 'Body'”. Then, the set
operator UNION ALL combines the results of the first query with the results of a
recursive query that multiplies subpart quantities by the number of parts in which
they are used. Note that the second query contains a recursive reference in the
INNER JOIN statement to the Common Table Expression named CarPartsCTE.
6. Drop worktables. 1. In the query editor, type the following code to drop the table you created.

DROP TABLE CarParts

2. Select the statement you just typed.


3. Press F5 to execute the statements.

Page 12 of 18
T-SQL Enhancements

Exercise 3
DDL Triggers and EventData()
Scenario
In previous versions of SQL Server, you can define AFTER triggers only for Data Manipulation Language (DML)
statements — INSERT, UPDATE, and DELETE. SQL Server 2005 allows you to define triggers for Data Definition
Language (DDL), and you can optionally define the scope to be an entire database or even an entire server, not just a
single object.
Within a trigger, you can get data regarding the event that initiated it by accessing the EventData() function. This
function returns a variable that uses the new xml data type. Each event’s schema inherits the Server Events base
schema.
In this exercise you will create DDL triggers and use EventData() to capture information about the calling event.

Tasks Detailed Steps


1. Add a new script in 1. Using SQL Server Management Studio, open the TSQLLab project created in
SQL Server the first exercise, if it's not still open.
Management Studio. 2. Right-click Queries in the Solution Explorer and click New Query.
NOTE: All of the code for this 3. When prompted for connection information, type “localhost” for the server
exercise is contained in the name, verify that the authentication method is set to Windows Authentication,
script file DDL_EventData.sql and click Connect.
in the C:\MSLabs\SQL Server
4. Right-click the script file and click Rename.
2005\Lab Projects\T-SQL Lab
directory. You can copy and 5. Rename the script DDL_EventData.sql.
paste from this file to
complete any portion of the
exercise.
2. Create a DDL 1. In the DDL_EventData.sql script, type the following code.
Trigger.
USE AdventureWorks
GO

CREATE TABLE DDLTest


(
a int NOT NULL
)
GO

CREATE TRIGGER safety


ON DATABASE
FOR DROP_TABLE
AS
PRINT 'You must disable Trigger "safety" to drop tables!'
ROLLBACK
GO

The code above first creates a table, and then creates a DDL trigger that will fire
when a user attempts to drop any database table.
2. Select the statements you just typed.
3. Press F5 to execute the query.
4. In the DDL_EventData.sql script, type the following query.

DROP TABLE DDLTest

Page 13 of 18
T-SQL Enhancements

Tasks Detailed Steps


5. Select the statement you just typed.
6. Press F5 to execute the query.
You will receive the following message:

You must disable Trigger "safety" to drop tables!


Msg 3609, Level 16, State 2, Line 1
Transaction ended in trigger. Batch has been aborted.

The DDL trigger returns an error message and prevents any table in the database
from being dropped by rolling back the transaction.
3. Alter the DDL 1. In the DDL_EventData.sql script, type the following code.
Trigger to use
EventData().
CREATE TABLE EventLog
(
PostTime datetime,
DBUser nvarchar(100),
Event nvarchar(100),
TSQL nvarchar(2000)
)
GO

ALTER TRIGGER safety


ON DATABASE
FOR DDL_DATABASE_LEVEL_EVENTS
AS
DECLARE @data xml
SET @data = EventData()
INSERT EventLog (PostTime, DBUser, Event, TSQL)
VALUES (GETDATE(), CONVERT(nvarchar(100), CURRENT_USER),
CONVERT(nvarchar(100), @data.query('data(//EventType)')),
CONVERT(nvarchar(2000), @data.query('data(//TSQLCommand)')))
GO

--Test the trigger


CREATE TABLE Foo (a INT)
DROP TABLE Foo
GO
SELECT *
FROM EventLog

The EventData() function returns information about server or database events. This
function returns an XML-typed variable.
2. Select the statements you just typed.
3. Press F5 to execute the query.
First, the code creates a log table to catch the event information. Second, the code
alters the trigger to write event data to the log table. The code stores the time, user,
event, and T-SQL associated with the event in the log table. Finally, the code tests
the altered trigger. Since the altered trigger does not include ROLLBACK, the
“foo” table is successfully deleted.
4. Drop worktables and 1. In the query editor, type the following DDL to drop the worktables you created.
trigger.
DROP TRIGGER safety
ON DATABASE
DROP TABLE DDLTest

Page 14 of 18
T-SQL Enhancements

Tasks Detailed Steps


DROP TABLE EventLog

2. Select the statement you just typed.


3. Press F5 to execute the DDL statements.

Page 15 of 18
T-SQL Enhancements

Exercise 4
Event Handling
Scenario
Previous versions of SQL Server require that you include error-handling code after every statement that might
produce an error. SQL Server 2005 introduces two new constructs, TRY and CATCH. These two constructs allow
you to handle transaction abort errors that would otherwise have resulted in the termination of a batch, provided that
those errors do not cause severance of the connection.
In this exercise, you will learn how to use TRY and CATCH blocks in T-SQL.

Tasks Detailed Steps


1. Add a new script in 1. Using SQL Server Management Studio, open the TSQLLab project created in
SQL Server the first exercise, if it's not still open.
Management Studio. 2. Right-click Queries in the Solution Explorer and click New Query.
NOTE: All of the code for this 3. When prompted for connection information, type “localhost” for the server
exercise is contained in the name, verify that the authentication method is set to Windows Authentication,
script file TRY_CATCH.sql in and click Connect.
the C:\MSLabs\SQL Server
2005\Lab Projects\T-SQL Lab 4. Right-click the script file and click Rename.
directory. You can copy and 5. Rename the script TRY_CATCH.sql
paste from this file to
complete any portion of the
exercise.
2. Create worktables. Create one table with a primary key and a second table with a foreign key that
limits values to those contained in the primary key column of the first table.
1. In the TRY_CATCH.sql script, type the following code.

USE AdventureWorks
GO

CREATE TABLE ExceptionT1


(
a int NOT NULL PRIMARY KEY
)
CREATE TABLE ExceptionT2
(
a int NOT NULL REFERENCES ExceptionT1(a)
)
GO

INSERT INTO ExceptionT1 VALUES (1)


INSERT INTO ExceptionT1 VALUES (3)
INSERT INTO ExceptionT1 VALUES (4)
INSERT INTO ExceptionT1 VALUES (6)

2. Select the statements you just typed.


3. Press F5 to execute the query.

Page 16 of 18
T-SQL Enhancements

3. Invoke a run-time When the SET XACT_ABORT option is set to OFF, only the Transact-SQL
error. statement that raised the error is rolled back and the transaction continues
processing.
1. In the TRY_CATCH.sql script, type the following query.

SET XACT_ABORT OFF


BEGIN TRAN
INSERT INTO ExceptionT2 VALUES (1)
INSERT INTO ExceptionT2 VALUES (2) /* Foreign Key Error */
INSERT INTO ExceptionT2 VALUES (3)
COMMIT TRAN
GO

2. Select the statements you just typed.


3. Press F5 to execute the query.
You should receive an error like the following:

Msg 547, Level 16, State 0, Line 1


INSERT statement conflicted with FOREIGN KEY constraint
'FK__ExceptionT2__a__36D11DD4. The conflict occurred in database
'AdventureWorks', table 'ExceptionT1', column 'a'.
The statement has been terminated.

Now, view the resulting table values.


4. In the TRY_CATCH.sql script, type the following query.

SELECT *
FROM ExceptionT1
GO

SELECT *
FROM ExceptionT2

5. Select the statements you just typed.


6. Press F5 to execute the query.
The first table, which you populated originally, has all four records. The second
table has two records, corresponding to valid primary key values. When SET
XACT_ABORT is OFF, the error is handled, but subsequent statements execute
successfully and the transaction is successfully committed.
4. Use the TRY/CATCH 1. In the TRY_CATCH.sql script, type the following code.
construct and invoke a
run-time error.
SET XACT_ABORT OFF
BEGIN TRY
BEGIN TRAN
INSERT INTO ExceptionT2 VALUES (4)
INSERT INTO ExceptionT2 VALUES (5) /* Foreign Key Error */
INSERT INTO ExceptionT2 VALUES (6)
COMMIT TRAN

Page 17 of 18
T-SQL Enhancements

PRINT 'Transaction committed'


END TRY
BEGIN CATCH
ROLLBACK
PRINT 'Transaction rolled back'
END CATCH
GO

2. Select the statements you just typed.


3. Press F5 to execute the query.
Notice that the results pane displays 'Transaction rolled back.
4. In the TRY_CATCH.sql script, type the following query.

SELECT *
FROM ExceptionT1
GO

SELECT *
FROM ExceptionT2

5. Select the statements you just typed.


6. Press F5 to execute the query.
Notice that the same two records are in ExceptionT2, even though two of the
second INSERT statements would not have violated the foreign key constraint.
When an unconditional ROLLBACK statement is issued in a CATCH block, the
entire transaction is terminated and rolled back on any error raised in the TRY
block, regardless of the SET XACT_ABORT setting.
5. Drop worktables. 1. In the query editor, type the following DDL to drop the worktables you created.

DROP TABLE ExceptionT2


DROP TABLE ExceptionT1

2. Select the statement you just typed.


3. Press F5 to execute the DDL statements.

Page 18 of 18

You might also like