output the contents of the root directory of the server to the console. : xp_cmdshell « System Settings « SQL Server / T-SQL Tutorial






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








26.44.xp_cmdshell
26.44.1.Granting PUBLIC permissions will cause you grief.
26.44.2.output the contents of the root directory of the server to the console.