ทำให้ sql server 2005 เขียน write file text ได้ โดยทำการเขียนไว้ใน Stored Procedures
If you receive an error similar to the one below it means that the extended procedure Command Shell (CmdShell) is not enabled. This is by default in SQL 2005 and can be easily rectified tow different ways.
Msg 15281, Level 16, State 1, Procedure xp_cmdshell, Line 1 SQL Server blocked access to procedure ‘sys.xp_cmdshell’ of component ‘xp_cmdshell’ because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of ‘xp_cmdshell’ by using sp_configure. For more information about enabling ‘xp_cmdshell’, see “Surface Area Configuration” in SQL Server Books Online.
The easiest way to resolve this issue is to run the following form the Query Analyzer from the Master Database:
Exec Master.dbo.Sp_Configure ‘Show Advanced Options’, 1
Exec Master.dbo.Sp_Configure ‘XP_CmdShell’, 1
A message similar to the one below will appear:
Configuration option ‘show advanced options’ changed from 1 to 1. Run the RECONFIGURE statement to install.
Configuration option ‘xp_cmdshell’ changed from 1 to 1. Run the RECONFIGURE statement to install.
For a GUI interface you can use the Surface Area Configuration tool by following the steps below:
1. Open the “Microsoft SQL Server 2005” program group.
2. Open the “Configuration Tools” subgroup.
3. Start the “SQL Server Surface Area Configuration” tool.
4. At the bottom of the SQL Server 2005 Surface Area Configuration task menu select: “Surface Area Configuration for Features”
5. Expand “MSSQLSERVER” and then expand “Database Engine” if needed.
6. Select “xp_cmdshell” and select the check box to “Enable xp_cmdshell” and finally click “OK” and close the window.