|
 |
|
SQL Server Tips by Burleson |
Precompiled headers
To speed up compilation time it is often a good idea to precompile
big chunks of code that change seldom or include files that are
common to several different modules. The first compilation process
to create the precompiled headers might be slow but, once it is
done, the compilation of the entire project will be faster.
It is a standard method to use the stdafx.h header file for setting
up precompiled headers by specifying in the project that a
precompiled header file (pch) will be created for this header file.
The remaining header files will use the same precompiled header
file. This is done by going to project settings, clicking on a .cpp
file and under the C/C++ tab selecting "precompiled headers" from
the "category" dropdown; from there it is a matter of selecting one
of the options to handle precompiled headers.
An alternative to use the project settings is to define an include
statement:
#include "stdafx.h"
#pragma hdrstop
By default, the XP wizard selects all precompiled headers' options
as "Automatic use of precompiled headers" but it is better to create
a precompiled header file for stdafx.h and use a precompiled header
file for the rest because Automatic Precompiling allows the compiler
to decide when to create and use precompiled headers. This is fine
but in many cases but it will not work when the precompiled header
files are not included in the same order for all source files in the
project. That is when creating a precompiled header file for
stdafx.h is used but it might as well be used as a general solution.
xp_hello2, Input parameter, output in the message window
After examining how to return some output from XP’s, it is time to
look into the input.
An XP can have both input and output parameters, the latter are
followed by the keyword OUTPUT or its short equivalent OUT. All
input parameters must be validated by the code, which is more
complicated than the code already seen for returning the output.
This is due to the fact that there is plenty of control over the
output but not over the input because of the many aspects to
consider: security, data type issues, error management, etc.
The above book excerpt is from:
Super SQL
Server Systems
Turbocharge Database Performance with C++ External Procedures
ISBN:
0-9761573-2-2
Joseph Gama, P. J. Naughter
http://www.rampant-books.com/book_2005_2_sql_server_external_procedures.htm |