Questions tagged [xp-cmdshell]

an extended stored procedure provided by SQL Server, which launches a Windows command shell to run a specified command. Not for general questions about cmd.exe or batch scripting; not related to Windows XP.

The xp_cmdshell extended stored procedure runs the command string given and returns any output as rows of text. The documentation (for SQL Server 2012) can be found here.

For security reasons, xp_cmdshell is disabled by default in recent versions of SQL Server.

264 questions
0
votes
3 answers

Using xp_cmdshell to export all tables into separate txt files

I am trying to export some data from one of my SQL Server database. It has a little over 300 tables and I didn't see any way to export this data using the SSMS wizard as it only does one table at a time. I need to use the delimiter "/". So I have…
unreal
  • 53
  • 6
0
votes
0 answers

SQL Server: The type initializer for 'Oracle.DataAccess.Client.OracleParameter' threw an exception

After googling out a lot this seems a unique situation hope I find answer to it. Problem: I am trying to execute a .net console application from SQL server using XP_CMDSHELL For e.g XP_CMDSHELL '\\sharedlocation\sharedfolder\dotnetconsoleapp.exe'…
Himanshu
  • 11
  • 2
0
votes
1 answer

write to file in SQL Server on Linux

I am testing SQL Server on Linux. I am trying to output a table from SQL Server to a file. Since xp_cmdshell is not available on Linux I cannot use BCP directly from SQL Server Management Studio. How can I write to file using SQL Server Management…
smucha
  • 55
  • 2
  • 7
0
votes
0 answers

Escaping backtick with sed via xp_cmdshell

I'm trying to edit an existing process we have that is called from SQL Server 2008r2 via xp_cmdshell. It replaces/removes certain characters in a csv file before it is then imported. I've managed to add in removing fullstops but am having trouble…
PChopra
  • 13
  • 3
0
votes
1 answer

How to copy file from 1 server computer to another using xp_cmdshell with credentials

How can I copy file from 1 server computer to another using xp_cmdshell with credentials.I have an application server and database server.I want to transfer a file from data server to application server by executing the xp_cmdshell command by using…
0
votes
1 answer

XP_CMDSHELL To run a SSIS Package w/ Parameters

I am trying to create a stored procedure that will allow me to pass in parameters to a SSIS Package. DECLARE @Path VARCHAR(200), @ExcelPath VARCHAR(50), @DB VARCHAR(100), @ExcelSheet VARCHAR(500), @Cmd VARCHAR(4000), @ReturnCode INT, @Msg…
Grim Rieber
  • 9
  • 1
  • 1
  • 7
0
votes
1 answer

Unable to access jarfile when using xp_cmdshell

I have a jar file that I want to call/run from an SQL stored procedure. To do this, I am using xp_cmdshell. I haven't created the stored procedure yet but, basically, the content of the stored procedure would be EXEC master..xp_cmdshell 'java -jar…
Krish
  • 319
  • 4
  • 19
0
votes
2 answers

SQL Server BCP function will not write a file

After downloading the BCP utility to sql server, I ran this code to allow me to run the BCP from inside SSMS: EXEC sp_configure 'show advanced options', 1 GO RECONFIGURE GO EXEC sp_configure 'xp_cmdshell', 1 GO RECONFIGURE GO Now I am trying to…
user1260251
  • 83
  • 1
  • 1
  • 8
0
votes
1 answer

I am not able to delete a .csv file using xp_cmdshell

I am getting an error Access is denied when I try deleting the csv file from a folder using xp_cmdshell. however I can delete .csv.gpg file successfully from the same location using xp_cmdshell. My query goes as: --delete the csv file from local…
0
votes
1 answer

xp_cmdshell command not executing last command when run as job

First off, before everybody shouts at me - I'm bug fixing in legacy code and a re-write is off the cards for now - I have to try to find a fix using the xp_cmdshell command. I have a proc which is executed via a scheduled job. The proc is full of…
Lawrence Phillips
  • 289
  • 1
  • 3
  • 12
0
votes
1 answer

Executing a .exe file in SQLplus

Is it possible to execute a .exe file from SQLPlus? In SQL2008 we could run a query like: exec master..xp_cmdshell 'FILE_PATH\file.exe' Is there an equivalent query for SQLPlus?
NeelDeveloper
  • 139
  • 1
  • 15
0
votes
1 answer

Unable to execute a '.exe' file from SQL Server 2008

I am trying to execute an .exe file from a SQL query. I am not sure whether the output I receive is valid. This is my query: exec master..xp_cmdshell 'dir C:\Users\My_PC\Desktop\Items\dist\runfile.exe' And I get the following result: Volume in…
NeelDeveloper
  • 139
  • 1
  • 15
0
votes
1 answer

Windows Server 2008 command works in CMD but not in batch file

I'm trying export csv (and other files) from numerous subfolders. These are archive folders that are being dropping dropped on our database server to be loaded. In any case I found two lines of code that work (or did work) but when loaded into a bat…
Ryan
  • 1
0
votes
1 answer

SQL EXEC xp_cmdshell

I am venturing into SQL injection over the past few days. I am able to leverage a SQL injection vulnerability to bypass login and ping back to my attacking machine from the same injection point using exec xp_cmdshell My question is how can I get…
0
votes
1 answer

Use of xp_cmdshell in SQL Server

I am trying to execute a perl script from xp_cmdshell. The output of the perl script is a csv file, but when I run EXEC master..xp_cmdshell N'perl G:\script\perl.pl'; I can't find the csv file created, though the xp_cmdshell command seems to run…
Giovanni De Ciantis
  • 357
  • 1
  • 2
  • 11