We've been using ASE for a long time, in the use of the process, in-depth understanding of its various functions, but for the extended stored procedures are basically not mentioned in the book, the Forum does not appear to have such problems, but it does solve some of the special problems, and the function is very powerful, I have studied this specifically and now share the results with you.
Sometimes you might have the need to do something with the server, such as copying files, starting or stopping certain services and programs, and so on. In general this case, PB can do nothing, only auxiliary to a large number of API functions, and often through the server operating system complex permissions control, Then you have to perform some operations, which are not generally available to PB developers. Extended stored procedures provide a convenient way for us.
1. Common Extended stored procedures:
xp_cmdshell: Performs certain operations on the server side as a command line. The command line function is very powerful and can almost do anything.
Extended stored procedures for the 2.mail series.
3. Custom stored procedures, in order to achieve some special features.
Here's how to use extended stored procedures, mainly with xp_cmdshell:
First, the extension of the stored procedure is the same as that of the ordinary procedure;
Similarly, you must have permission to invoke the extension process;
There is a special place for xp_cmdshell: It enforces more restrictive permissions and, even with SA privileges, cannot be executed by default, and you must restart the server using sp_configure to modify the server Configuration "xp_cmdshell context" to 0. Has the ability to own a permission.
Here we start by xp_cmdshell, get the server time, very simple:
Open the PB database artboard, connect to the database with the SA user, and enter:
exec xp_cmdshell ' date ';
The system will return the server time.
Then we perform a copy of the C: Disk file Test.txt Copy to D: Disk:
exec xp_cmdshell "copy c:\test.txt d:\test.txt";