41
NULL
NULL
Values
Values
• Transact-SQL also offers an extension for null
processing.
• If the option ANSI_NULLS is set to OFF,
comparisons between nulls, such as NULL = NULL,
evaluate to TRUE. Comparisons between NULL and
any data value evaluate to FALSE.
42
Stored procedures
Stored procedures
• Microsoft’s implementation of SQL-2003 PSM
• When using Transact-SQL programs, two methods
are available for storing and executing the programs.
– You can store the programs in the client and
create applications that send the commands to
SQL Server and process the results.
– You can store the programs as stored procedures
in SQL Server and create applications that
execute the stored procedures and process the
results.
43
Benefits of Stored Procedures
Benefits of Stored Procedures
• The benefits of using stored procedures in SQL
Server rather than Transact-SQL programs stored
locally on client computers are:
– They can have security attributes (such as
permissions). Users can be granted permission to
execute a stored procedure without having to have
direct permissions on the objects referenced in the
procedure.
– They can enhance the security of your application.
Parameterized stored procedures can help protect
your application from SQL Injection attacks.
44
Benefits of Stored Procedures
Benefits of Stored Procedures
– They allow modular programming.
You can create the procedure once, and call it any
number of times in your program. This can
improve the maintainability of your application and
allow applications to access the database in a
uniform manner.
– They can reduce network traffic.
An operation requiring hundreds of lines of
Transact-SQL code can be performed through a
single statement that executes the code in a
procedure, rather than by sending hundreds of
lines of code over the network.