SQL Server/T-SQL Tutorial/System Settings/xp cmdshell

Материал из SQL эксперт
Версия от 10:23, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Granting PUBLIC permissions will cause you grief.

The syntax of this stored procedure is xp_cmdshell "command"[,no_output]   
 
xp_cmdshell "dir c:\"


output the contents of the root directory of the server to the console.

5>
6>
7>     DECLARE @myresult int
8>     EXEC @myresult = xp_cmdshell "dir c:\tim.txt"
9>     IF (@myresult = 0)
10>         PRINT "Success"
11>     ELSE
12>         PRINT "Failure"
13>     GO
Msg 15281, Level 16, State 1, Server J\SQLEXPRESS, 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 c
an 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.
Failure