Activar Ole Automation Procedures en SQL Server

Los procedimientos Ole Automation pueden ser configurados como el xp_cmdshell desde el la herramienta Surface Area Configuration o bien desde el sp_configure. Estos vienen deshabilitados por defecto en la instalación de SQL Server.

Si queres utilizar el objeto FileSystem (FSO) para trabajar con archivos, ya sea creando, borrando, copiando o moviendo archivos o carpetas el OLE Automation es la solución.

La siguiente es una lista de los procedimiento que necesitaras tener en mente cuando trabajes con FSO desde un SQL Server.

  • sp_OACreate
  • sp_OADestroy
  • sp_OAGetProperty
  • sp_OASetProperty
  • sp_OAMethod
  • sp_OAGetErrorInfo
  • sp_OAStop

 

Necesitaras activar los procedimientos Ole Automation utilizando sp_configure o el GUI.

start -> programs ->MS sql 2005 -> configuration tools -> surfce area configuration -> Surface area conf for features -> Ole automation -> select the Enable check box and saved

O bien

exec sp_configure
Go

exec sp_configure 'Ole Automation Procedures', 1
-- Configuration option 'Ole Automation Procedures' 
-- changed from 0 to 1. Run the RECONFIGURE statement 
-- to install.
go
reconfigure
go

Cuando veas alguno de estos mensajes de error será porque todavía no lo activaste:

Msg 15281, Level 16, State 1, Procedure sp_OACreate, Line 1
SQL Server blocked access to procedure ‘sys.sp_OACreate’ of component ‘Ole Automation Procedures’ because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of ‘Ole Automation Procedures’ by using sp_configure. For more information about enabling ‘Ole Automation Procedures’, see “Surface Area Configuration” in SQL Server Books Online.

Msg 15281, Level 16, State 1, Procedure sp_OAMethod, Line 1
SQL Server blocked access to procedure ‘sys.sp_OAMethod’ of component ‘Ole Automation Procedures’ because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of ‘Ole Automation Procedures’ by using sp_configure. For more information about enabling ‘Ole Automation Procedures’, see “Surface Area Configuration” in SQL Server Books Online.

Msg 15281, Level 16, State 1, Procedure sp_OADestroy, Line 1
SQL Server blocked access to procedure ‘sys.sp_OADestroy’ of component ‘Ole Automation Procedures’ because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of ‘Ole Automation Procedures’ by using sp_configure. For more information about enabling ‘Ole Automation Procedures’, see “Surface Area Configuration” in SQL Server Books Online.

SQL Server blocked access to procedure ‘sys.sp_OADestroy’ of component ‘Ole Automation Procedures’ because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of ‘Ole Automation Procedures’ by using sp_configure. For more information about enabling ‘Ole Automation Procedures’, see “Surface Area Configuration” in SQL Server Books Online.