1

I'm using SQL Server as a service on a MS Azure VM and I would like to use xp_cmdshell in a stored procedure but I get the below error/information message:

The module 'ProcExportFacturaEDI_Manual2' depends on the missing object 'xp_cmdshell'. The module will still be created; however, it cannot run successfully until the object exists.

I read online and find out that in MS Azure is not working. Does anyone know what's the equivalent of it or how can I use it in Azure?

EDIT

I did install it, but I get the below message and the file that should be exported, is not there:

(1 row(s) affected) Msg 2812, Level 16, State 62, Line 119 Could not find stored procedure 'xp_cmdshell'.

  • 2
    Possible duplicate of [alternative xp\_cmdshell in sql azure](https://stackoverflow.com/questions/33407800/alternative-xp-cmdshell-in-sql-azure) – alroc Jun 13 '18 at 11:40
  • I see in your edit that you installed it but I don't see how that is possible since it's a system extended stored procedure. See the answer by @alroc. – Dan Guzman Jun 13 '18 at 12:08

2 Answers2

3

Azure SQLDB does not support xp_cmdshell. Full stop. There is no "equivalent" because Azure SQLDB runs in a shared environment without access to the host unlike the standalone, full access to the host environment you're used to with your on-premises instances.

You will need to rewrite your stored procedure to not use it. We cannot tell you what the "equivalent" would be because we do not have access to your stored procedure, nor do we know the requirements.

If you cannot avoid using xp_cmdshell, then Azure SQLDB may not be for you. You'll want to look at setting up a VM running SQL Server on Azure (IaaS).

alroc
  • 27,574
  • 6
  • 51
  • 97
0

SQL Azure does not provide access to a command prompt. Think of SQL Azure as just a virtualized service, without host infrastructure (Virtualized or physical).

If the stored procedure you mentioned needs to create a file, you can create an Azure Function to create a file to an Azure BLOB Storage account instead.

Alternatively, you can find xp_cmdshell available on Azure SQL Server VM (IaaS).

Alberto Morillo
  • 13,893
  • 2
  • 24
  • 30