You are on page 1of 20

Microsoft Virtual Labs

What's new in SQL Server 2008 for


Database Administrators?
What's new in SQL Server 2008 CTP4 for OLTP Applications

Table of Contents
What's new in SQL Server 2008 CTP4 for OLTP Applications .............................................. 1
Exercise 1 Change Data Capture in Action ...................................................................................................................2
Exercise 2 DATE/TIME datatype in SQL Server 2008 .................................................................................................6
Exercise 3 Implementing a naming convention policy using Declarative Management Framework (DMF) .............. 11
Exercise 4 Implementing table valued parameters ...................................................................................................... 15
What's new in SQL Server 2008 CTP4 for OLTP Applications

What's new in SQL Server 2008 CTP4 for


OLTP Applications
After completing this lab, you will be better able to:
Objectives  Implement and work with Change Data Capture
 Use the new datatypes included in SQL Server 2008
 Implement a naming convention policy using Declarative Management
Framework
 Implement Table Valued Parameters

In these series of exercises you will get a good understanding of the new features
Scenario in SQL Server 2008. You will learn and understand how to implement and work
with Change Data Capture, discover the new features of Database Mirroring, as
well as implement Table Valued Parameters. One of the other features you will
discover in the exercises is the use of the new date datatypes.

In order to benefit from these new features it will be important to familiarize


yourself with the technologies presented in these exercises.

Note: This lab is tested with SQL Server 2008 codename ‘Katmai’ CTP 4. The
documentation and instructions in this lab is pre-release and is subject to change
in future release.

Estimated Time to 60 Minutes


Complete This Lab

Computers used in this


Lab SQL2008CTP

The password for the Administrator account on all computers in this lab is:
Pass@word1.

Page 1 of 18
What's new in SQL Server 2008 CTP4 for OLTP Applications

Exercise 1
Change Data Capture in Action

Scenario
Change data capture is designed to capture insert, update, and delete activity applied to SQL Server tables, and to
make the details of the changes available in an easily consumed relational format. The change tables used by change
data capture contain columns that mirror the column structure of a tracked source table, along with the metadata
needed to understand the changes that have occurred.

Note: Lab Scripts - In order to assist you completing the hands-on-labs a .sql script file for every exercise in this lab
has been created inside the virtual machine. The scripts for this lab can be found on the desktop under the SQL 2008
HOLs shortcut.

Tasks Detailed Steps


Complete the following a. The machine has been pre-logged on as Administrator, using a password of
10 tasks on: Pass@word1.
b. Click Start | All Programs | Microsoft SQL Server code name Katmai | SQL
SQL2008CTP Server Management Studio menu.
c. Click ‘Connect’ in the “Connect to Server” dialog box after ensuring the
1. Start SQL Server following settings:
Management Studio • Server type: Database Engine
• Server name: SQL2K8
• Authentication: Windows Authentication
Note: You may need to change the server name if required.
2. Initialize the Lab a. Click on ‘File | Open | File’ in the standard toolbar.
Environment b. Browse to the SQL 2008 HOL ShortCut on the desktop and open the
InitializeLab.SQL script in the What is New in SQL 2008 Folder.

The following content will display:


CREATE DATABASE SQL2008CDC
GO
USE SQL2008CDC;
GO
EXEC sp_cdc_enable_db_change_data_capture;
GO
USE SQL2008CDC
GO
CREATE TABLE dbo.Employee(
EmpID int Primary Key NOT NULL,
EmpName nvarchar(100) NOT NULL,
EmpEmail nvarchar(100) NOT NULL)
GO

EXEC sp_cdc_enable_table_change_data_capture 'dbo', 'Employee', @role_name

Page 2 of 18
What's new in SQL Server 2008 CTP4 for OLTP Applications
Tasks Detailed Steps
= NULL, @supports_net_changes =1;
GO

c. Run the statement(s) by clicking ‘Execute’ on the standard toolbar or by pressing


‘F5’
3. Insert a record in the a. Delete all the statement(s) or click on ‘New Query’ in the standard toolbar.
Employee table b. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or
by pressing ‘F5’

use SQL2008CDC
GO
INSERT INTO dbo.Employee
values (1, N'John Wills', N'jw@contoso.com')
GO
4. Update the inserted a. In the same query window, delete the previous statement(s).
data b. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or
by pressing ‘F5’

use SQL2008CDC
GO
UPDATE dbo.Employee SET EmpName = N'Don Miles' WHERE EmpID = 1;
GO
5. Using the Note: Let’s understand the query - cdc.lsn_time_mapping table is created when we
cdc.fn_cdc_get_all_c enable CDC as shown in the previous exercise. It returns one row for each transaction
hanges_<capture_ins having rows in a change table. This table is used to map between log sequence
tance> number (LSN) commit values and the time the transaction committed.
We can use the sys.fn_cdc_map_lsn_to_time and sys.fn_cdc_map_time_to_lsn system
functions to query the table. One strategy is to begin by querying for the minimum and
maximum LSN values for the capture instance. As shown in the following example, this
method returns all changes associated with the current change data capture timeline
for the capture instance.
a. If the query window is open, delete all the statement(s) or click on ‘New Query’
in the standard toolbar.
b. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or
by pressing ‘F5’

use SQL2008CDC
GO
DECLARE @from_lsn binary(10), @to_lsn binary(10);
SET @from_lsn = sys.fn_cdc_get_min_lsn('dbo_employee');
SET @to_lsn = sys.fn_cdc_get_max_lsn();
SELECT * FROM cdc.fn_cdc_get_all_changes_dbo_employee(@from_lsn,
@to_lsn, 'all');
GO

You will notice that 2 records are displayed (one for insert and another for update

Page 3 of 18
What's new in SQL Server 2008 CTP4 for OLTP Applications
Tasks Detailed Steps
operation)
Note: When querying for all changes in a specified interval, the row filter option 'all'
is commonly used. This option returns all changes, but for an operation, only the after
image is returned. To retrieve both the row containing the values before the update
and the row containing the values after the update, the row filter option 'all update
old' should be used.

Note: The caller can retain the value of @to_lsn so that it can be used to determine an
appropriate range for a subsequent request.
6. Using the a. In the same query window, delete the previous statement(s).
cdc.fn_cdc_get_net_ b. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or
changes_<capture_in
by pressing ‘F5’
stance>

use SQL2008CDC
GO
DECLARE @from_lsn binary(10), @to_lsn binary(10);
SET @from_lsn = sys.fn_cdc_get_min_lsn('dbo_employee');
SET @to_lsn = sys.fn_cdc_get_max_lsn();
SELECT * FROM cdc.fn_cdc_get_net_changes_dbo_employee(@from_lsn,
@to_lsn, 'all');

You will notice that only 1 record is returned which is the final (net) change (only
the updated operation)
Note: The above query may take slightly longer than expected when it is being run for
the first time.
7. Query the change a. If the query window is open, delete all the statement(s) or click on ‘New Query’
data in the standard toolbar.
b. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or
by pressing ‘F5’

use SQL2008CDC
GO
DECLARE @from_lsn binary(10), @to_lsn binary(10);
SET @from_lsn = sys.fn_cdc_get_min_lsn('dbo_employee');
SET @to_lsn = sys.fn_cdc_get_max_lsn();
SELECT * FROM cdc.fn_cdc_get_all_changes_dbo_employee(@from_lsn,
@to_lsn, 'all')

Note: You will notice that both the insert and update operations are being shown.
8. Clean the CDC table Note: Information - sp_cdc_cleanup_change_table removes rows from the change
until the last table in the current database based on the specified low_water_mark value.
operation This stored procedure is provided for users who want to directly manage the change
table cleanup process. Caution should be used, however, because the procedure
affects all consumers of the data in the change table.
a. In the same query window, delete the previous statement(s).
b. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or

Page 4 of 18
What's new in SQL Server 2008 CTP4 for OLTP Applications
Tasks Detailed Steps
by pressing ‘F5’

use SQL2008CDC
GO
DECLARE @end_time datetime;
DECLARE @to_lsn binary(10);
SET @end_time = GETDATE();
SELECT @to_lsn = sys.fn_cdc_map_time_to_lsn('largest less than or equal',
@end_time);
exec sys.sp_cdc_cleanup_change_table @capture_instance = 'dbo_employee',
@low_water_mark=@to_lsn
9. Close SQL Server a. Close SQL Server Management Studio without saving changes.
Management Studio

Page 5 of 18
What's new in SQL Server 2008 CTP4 for OLTP Applications

Exercise 2
DATE/TIME datatype in SQL Server 2008

Scenario
In SQL Server 2008 additional support for date and time data is provided by the introduction of new datatypes. The
introduction of these new datatypes allow you to better store and work with date and time data, including multiple
time zones and enhanced date calculations.

The new datatypes consist of:


• datetime2
• date
• time
• datetimeoffset

Besides these new datatypes a new set of date and time related functions are introduced. In this exercise you will
implement the new SQL Server 2005 date/time datatypes and explore new built-in-functions and features.

Tasks Detailed Steps


Complete the following a. Click Start | All Programs | Microsoft SQL Server code name Katmai | SQL
10 tasks on: Server Management Studio menu.
b. Click ‘Connect’ in the “Connect to Server” dialog box after ensuring the
SQL2008CTP following settings:
• Server type: Database Engine
1. Start SQL Server • Server name: SQL2K8
Management Studio • Authentication: Windows Authentication
Note: You may need to change the server name if required.
2. Create a LABDB a. Click on ‘New Query’ in the standard toolbar.
database b. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or
by pressing ‘F5’

CREATE DATABASE LABDB


3. Identify the new Note: Information - sys.systypes is a system view that will keep track of all datatypes
datatypess defined in the SQL Server 2008 Database Engine
a. In the same query window, delete the previous statement(s).
b. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or
by pressing ‘F5’

select * from sys.systypes where name like '%date%' or name like '%time%'

The query result will look similar as in the picture below:

Page 6 of 18
What's new in SQL Server 2008 CTP4 for OLTP Applications
Tasks Detailed Steps

Note that the following datatypes are new in SQL Server 2005: Datetime2,
datetimeoffset, date, time

4. Create a table with a. In the same query window, delete the previous statement(s).
the new datatypes b. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or
by pressing ‘F5’

USE LABDB
GO
CREATE TABLE TBL_NewDatetimetypes (DateValue date, Timevalue Time,
DateTimeOffset datetimeoffset, Datetime2value datetime2)
5. Insert data in the a. In the same query window, delete the previous statement(s).
table b. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or
by pressing ‘F5’

INSERT INTO TBL_NewDatetimetypes values


(SYSDATETIME(),SYSDATETIME(),SYSDATETIMEOFFSET(),SYSUTCDA
TETIME())

Note: The above statement is using the following functions:

SYSDATETIME - Returns the current database system timestamp as a datetime2(7)


value. The database time zone offset is not included. This value is derived from the
operating system of the computer on which the instance of SQL Server is running.

SYSDATETIMEOFFSET - Returns the current database system timestamp as a


datetimeoffset(7) value. This value is derived from the operating system of the
computer on which the instance of SQL Server is running. SYSDATETIME and
SYSUTCDATETIME have more fractional seconds precision than GETDATE and
GETUTCDATE. SYSDATETIMEOFFSET includes the system time zone offset.
SYSDATETIME, SYSUTCDATETIME, and SYSDATETIMEOFFSET can be
assigned to a variable of any of the date and time types.

SYSUTCDATETIME - Returns the current database system timestamp as a datetime


value. The database time zone offset is not included. This value represents the current
UTC time (Coordinated Universal Time). This value is derived from the operating

Page 7 of 18
What's new in SQL Server 2008 CTP4 for OLTP Applications
Tasks Detailed Steps
system of the computer on which the instance of SQL Server is running
c. In the same query window, delete the previous statement(s).
d. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or
by pressing ‘F5’

SELECT * FROM TBL_NewDatetimetypes

The query result will look similar as in the picture below:

6. Understanding the Note: Based on the previous query results you should understand that the new
stored data datatypes in SQL Server support the following storage:

This will allow you for a more granular storage of date and time data in SQL Server
2008.
7. Using the Note: Information - The datetimeoffset datatype allows you to store the timezone
datetimeoffset identifier together with the date value.
datatype
a. In the same query window, delete the previous statement(s).
b. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or
by pressing ‘F5’

Page 8 of 18
What's new in SQL Server 2008 CTP4 for OLTP Applications
Tasks Detailed Steps
Create table tbl_timezones (Entryid int identity(1,1),
Currenttime datetimeoffset)
GO
insert into tbl_timezones (currenttime)
values ('1998-09-20 7:45:50.71345 -5:00')
insert into tbl_timezones (currenttime)
values ('1956-01-27 6:45:50.00000 -3:00')
insert into tbl_timezones (currenttime)
values ('1972-12-18 7:45:50.71345 +1:00')
insert into tbl_timezones (currenttime)
values ('2005-01-20 7:12:50.71345 +9:00')
insert into tbl_timezones (currenttime)
values ('2005-01-20 01:00:00.00000 +4:00')
8. Use the DATEPART a. In the same query window, delete the previous statement(s).
function to return the b. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or
timezone offset for
by pressing ‘F5’
the current database

select datepart(TZoffset,sysdatetimeoffset())

Note: Depending on the server timezone settings this will return the value in minutes
from the GMT standard time. This will be -420 for PST, 60 for GMT+1

Note: Information - The DATEPART function has been extended to return the
timezone value from a given timezone, the TZoffset value is returned in a number,
representing the number in minutes from GMT standard time. So PST (GMT - 7) will
return the value of -420.
9. Use the a. In the same query window, delete the previous statement(s).
SWITCHOFFSET b. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or
function to return a
by pressing ‘F5’
date in a different
timezone
select currenttime,SWITCHOFFSET ( currenttime,
datepart(TZoffset,sysdatetimeoffset())) as TimeinCurrentTimezone
from tbl_timezones

The query result will look similar to:

Page 9 of 18
What's new in SQL Server 2008 CTP4 for OLTP Applications
Tasks Detailed Steps
10. Close SQL Server a. Close SQL Server Management Studio without saving changes.
Management Studio

Page 10 of 18
What's new in SQL Server 2008 CTP4 for OLTP Applications

Exercise 3
Implementing a naming convention policy using Declarative
Management Framework (DMF)

Scenario
In this exercise you will create a naming policy that will force users to create objects using the appropriate naming
conventions as defined within the companies policy standard. You are required to only allow the creation of tables
when they start with 'tbl' as the object name identifier. Since you don't want the policy to interfere with other
applications you will implement a filter that will apply the policy only to the Adventureworks database.

Tasks Detailed Steps


Complete the following 6 a. Click Start | All Programs | Microsoft SQL Server code name Katmai | SQL
tasks on: Server Management Studio menu.
b. Click ‘Connect’ in the “Connect to Server” dialog box after ensuring the
SQL2008CTP following settings:
• Server type: Database Engine
1. Start SQL Server • Server name: SQL2K8
Management Studio • Authentication: Windows Authentication
Note: You may need to change the server name if required.
2. Create the ‘Table a. In Object Explorer window, expand Management, expand Policy Management,
Naming Convention’ expand Facets, right-click Table Facet, and then click New Condition.
condition

b. In the Create New Condition dialog box, in the Name box, type Table starts
with tbl.
c. In the Facet box, confirm that Table Facet is selected.
d. In the Expression area, in the Field box, select Name, in the Operator box select
LIKE, and in the Value type tbl%.
e. Optionally, you can type a description of the condition, by clicking on the
Description tab.
f. The dialog box should look similar to as shown below.

Page 11 of 18
What's new in SQL Server 2008 CTP4 for OLTP Applications
Tasks Detailed Steps

g. Click ‘OK’ to create the condition.


3. Create the ‘Table a. In Object Explorer window, right-click Policies, and then click New Policy.
Naming
Conventions’ policy

b. In the Create New Policy dialog box, in the Name box, type Table Naming
Conventions.
c. Select the Enabled box.
d. In the Condition box, select Table Starts with TBL.
e. In Applies to: select Server/Database/Table.
f. Click on Edit Filter to set the appropriate filter to only Adventureworks
g. In the Policy Target Filter dialog box, select Database
h. In Filter select Name from the Fields List and type Adventureworks in the
Value Box.
i. The dialog box should look similarto as shown below:

Page 12 of 18
What's new in SQL Server 2008 CTP4 for OLTP Applications
Tasks Detailed Steps

j. Click OK.
k. In the Create New Policy dialog box, check Enforce in the Execution mode.
l. The dialog box should look similar to as shown below:

m. Click OK.
4. Create a new table to a. Click on ‘New Query’ in the standard toolbar.
test if the policy gets b. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or
applied
by pressing ‘F5’

USE ADVENTUREWORKS
CREATE TABLE failedpolicy (policyid int)

You will notice that this table does not comply with the naming conventions and
therefore will not pass the policy check.
c. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or
by pressing ‘F5’

CREATE TABLE tbl_passedpolicy (policyid int)


You will notice that this table gets created successfully.

Page 13 of 18
What's new in SQL Server 2008 CTP4 for OLTP Applications
Tasks Detailed Steps
5. Disable the policy a. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or
by pressing ‘F5’

EXEC MSDB.DBO.SP_SYSPOLICY _UPDATE_POLICY


@name = 'Table Naming Conventions',
@is_enabled = 0

Note: Although you can use the GUI to disable policies, it is also possible to use a set
of system stored procedures to define and create DMF components. Books Online
provides you with an overview of the system stored procedures and metadata used by
DMF components that are defined and stored in the MSDB database.
6. Close SQL Server a. Close SQL Server Management Studio without saving changes.
Management Studio

Page 14 of 18
What's new in SQL Server 2008 CTP4 for OLTP Applications

Exercise 4
Implementing table valued parameters

Scenario
Table-valued parameters are a new parameter type in SQL Server 2008. Table-valued parameters are declared by
using user-defined table types. You can use table-valued parameters to send multiple rows of data to a Transact-SQL
statement or a routine, such as a stored procedure or function, without creating a temporary table or many
parameters.

Table-valued parameters are like parameter arrays in OLE DB and ODBC, but offer more flexibility and closer
integration with Transact-SQL. Table-valued parameters also have the benefit of being able to participate in set-
based operations

In this exercise your goal is to insert a entire set of data using multiple rows by using a single stored procedure.
Before SQL Server 2008, there was no integrated functionality that supported to call a stored procedure to achieve
that goal, using on server round trip. You will implement the workarounds that were existing pre-table valued
parameters and then implement the solution using table valued parameters.

Tasks Detailed Steps


Complete the following a. Click Start | All Programs | Microsoft SQL Server code name Katmai | SQL
13 tasks on: Server Management Studio menu.
b. Click ‘Connect’ in the “Connect to Server” dialog box after ensuring the
SQL2008CTP following settings:
• Server type: Database Engine
1. Start SQL Server • Server name: SQL2K8
Management Studio • Authentication: Windows Authentication
Note: You may need to change the server name if required.
2. Create a new table a. Click on ‘New Query’ in the standard toolbar.
b. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or
by pressing ‘F5’

USE AdventureWorks
GO
CREATE TABLE dbo.Employee(
EmpID int NOT NULL,
EmpName nvarchar(100) NOT NULL,
EmpEmail nvarchar(100) NOT NULL)
3. Create a new stored a. In the same query window, delete the previous statement(s).
procedure that will b. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or
insert data into the
by pressing ‘F5’
Employee table

USE AdventureWorks
GO
CREATE PROCEDURE NewEmployeeMS(@EmpID int,@EmpName

Page 15 of 18
What's new in SQL Server 2008 CTP4 for OLTP Applications
Tasks Detailed Steps
nvarchar(100),@EmpEmail nvarchar(100))
As
BEGIN
INSERT INTO dbo.Employee
values(
@EmpID, @EmpName, @EmpEmail)
END

Note: The stored procedure accepts three parameters to insert data into the table.
4. Execute the stored a. In the same query window, delete the previous statement(s).
procedure passing in b. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or
the required
by pressing ‘F5’
parameters

use AdventureWorks
Go

execute NewEmployeeMS 1,'John McLean','JohnMcLean@contoso.com'

execute NewEmployeeMS 2,'Bob Smith','BobSmith@contoso.com'

execute NewEmployeeMS 3,'Ted Connery','TedConnery@contoso.com'

Note: The stored procedure has to be run three times to insert the required data.
5. Verify the data in a. If the query window is open, delete all the statement(s) or click on ‘New Query’
dbo.Employee table in the standard toolbar.
b. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or
by pressing ‘F5’

USE AdventureWorks
GO
select * from dbo.Employee;

Note: Drawbacks of the above solution -


• Multiple round trips
• Stored procedure needs to be executed multiple times
• Inefficient code
6. Delete all the records a. Click on ‘New Query’ in the standard toolbar.
in the Employee b. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or
table
by pressing ‘F5’

USE AdventureWorks
GO
truncate table dbo.Employee

Page 16 of 18
What's new in SQL Server 2008 CTP4 for OLTP Applications
Tasks Detailed Steps
7. Verify that there is a. In the same query window, delete the previous statement(s).
no data in b. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or
dbo.Employee table
by pressing ‘F5’

USE AdventureWorks
GO
select * from dbo.Employee
8. Create a new table a. In the same query window, delete the previous statement(s).
type b. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or
by pressing ‘F5’

USE AdventureWorks
GO
CREATE TYPE EmployeeTableType AS TABLE
(EmpID INT, EmpName nvarchar(100), EmpEmail nvarchar(100));
Go
9. You can browse the
new table type in
Object Explorer

10. Create a stored a. In the same query window, delete the previous statement(s).
procedure that will b. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or
use the new table
by pressing ‘F5’
type

USE AdventureWorks
GO
CREATE PROCEDURE NewEmployee(@EmployeeDetails
EmployeeTableType READONLY)
As
BEGIN
INSERT INTO dbo.Employee
SELECT * FROM @EmployeeDetails
END

Note: Table-valued parameters must be passed as input READONLY parameters to


Transact-SQL routines. You cannot perform DML operations such as UPDATE,
DELETE, or INSERT on a table-valued parameter in the body of a routine.
11. Execute the stored a. In the same query window, delete the previous statement(s).
procedure b. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or

Page 17 of 18
What's new in SQL Server 2008 CTP4 for OLTP Applications
Tasks Detailed Steps
by pressing ‘F5’

use AdventureWorks
Go
DECLARE @NewEmployees EmployeeTableType

INSERT INTO @NewEmployees


VALUES(1,'John McLean','JohnMcLean@contoso.com')
INSERT INTO @NewEmployees
VALUES(2,'Bob Smith','BobSmith@contoso.com')
INSERT INTO @NewEmployees
VALUES(3,'Ted Connery','TedConnery@contoso.com')

EXECUTE NewEmployee @NewEmployees


Go

Note: After the routine is out of scope, the table-valued parameter is no longer
available. However, the type definition remains until it is dropped.
12. Verify the data in a. If the query window is open, delete all the statement(s) or click on ‘New Query’
dbo.Employee table in the standard toolbar.
b. Run the following statement(s) by clicking ‘Execute’ on the standard toolbar or
by pressing ‘F5’

USE AdventureWorks
GO
select * from dbo.Employee

Note: Benefits of using Table-valued parameters - Table-valued parameters offer


more flexibility and in some cases better performance than temporary tables or other
ways to pass a list of parameters. Table-valued parameters offer the following
benefits:
• Have a well defined scope at the end of which they are automatically cleared.
• Do not acquire locks for the initial population of data from a client.
• Do not cause a statement to recompile.
• Provide a simple programming model.
• Enable you to include complex business logic in a single routine.
• Reduce round trips to the server.
• Can have a table structure of different cardinality.
• Are strongly typed.
• Enable the client to specify sort order and unique keys.
• In short, one round trip, compact & clean code. It's nice.
13. Close SQL Server a. Close SQL Server Management Studio without saving changes.
Management Studio

Page 18 of 18

You might also like