It has been used for a long time using ASE. In the process of use, it will continue to understand its various functions, but there is basically no books in the extended stored procedure, and there is no such problem in the forum. However, it does solve some of the special problems, and the function is very powerful. I have specialized in research. I will share the results with everyone. Sometimes everyone may have this need, it is necessary to make some operations for the server. For example, copy files, start or stop certain services and programs. In this case, PB will not force, only to assist in many API functions, and often to control the complicated privileges through the server, then also execute Some operations, this is not a general PB developer to be able to do with it. The expansion stored procedure provides us with a convenient way.
1. Common extension stored procedures: XP_cmdshell: Perform some operations in the server side in a command line. The function of the command line is very powerful, almost anything can be done.
2. Extension stored procedure for the Mail series.
3. Customized stored procedures, in order to achieve some special features.
Below we mainly explain how to use extended stored procedures with XP_cmdshell:
First extend the stored procedure, its call mode, and the way of calling the normal process;
Similarly, there must be permission to call the extension process; there is also a special place for xp_cmdshell: it performs a more stringent permission control, even if there is SA permission, it is not possible to execute it, you must use the sp_configure modification server configuration "xp_cmdshell CONTEXT "is 0, restart the server," this permission is available.
Below we started through XP_CMDSHELL, it is very simple to get the server.
Open the PB database drawing board, connect the database with the SA user, enter:
EXEC XP_CMDSHELL 'DATE';
The system will return server time.
Then we perform a copy, copy the file Test.txt of the disk to D: Pat:
EXEC XP_CMDSHELL "COPY C: /TEST.TXT D: /TEST.TXT";
Finally, let's take a look at how the custom stored procedure is implemented (there is no suitable DLL, no tried):
Suppose I now need to copy the screen of the server, save to the hard disk,
First, copy the DLL to be used to the system directory, such as XP is widows / system32;
Secondly create an extended stored procedure, open the extended stored procedure with SCVIEW, enter the process name equal to the function name to be called in the DLL. For example, the DLL function I want to use is DSCreenTobmp, then specify the name of the DLL, such as ScreenTobmp.dll, create carry out.
Then call this expansion process in the PB's database painting board:
Exec dscreentobmp '' 'c: /aa.bmp ";
After the execution is complete, you will see the copy server image in C: /.