Ejecutar líneas de comando desde SQL SERVER
Varias personas me preguntaron si es posible crear archivos usando SQL de SQL Server. La respuesta es sí. Existe el procedimiento almacenado xp_cmdshell que permite ejecutar comandos cmd. Con xp_cmdshell usted puede crear archivos, ver directorios borrar archivos, crear carpetas, etc, etc, etc, utilizando el T-SQL de SQL Server. Ejemplo: En este ejemplo, voy a crear un directorio llamado Daniel en el disco c: usando el procedimiento almacenado xp_cmdshell desde el sql server management studio o alguna otra herramienta de su preferencia: Xp_cmdshell ‘mkdir c:\daniel’ Es muy probable que usted al ejecutar el procedimiento almacenado, le salga el siguiente error: 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 usi...