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
1 answer

How to Execute SVN Update command through SQL xp_CMDShell

I have installed Tortoise SVN on my machine, i want to update my local copy with SVN using SVN UPDATE command. I am using SQL script EXEC master..xp_CMDShell 'svn update D:\SVN_WorkingFolder' This script is not executing. May i know where i am…
0
votes
1 answer

xp_cmdshell error with remote DB connection

I have two VM servers (A&B) loaded with SQL server. I have connected to the remote SQL server on B from server A (node of a clustered SQL server). Can I rename a file on server B using xp_cmdshell over the DB connection? I am getting the below error…
-1
votes
1 answer

How to stop XP_cmdshell (kill/Rollback)

I observed that xp_cmdshell is in KILLED/ROLLBACK state in my SQL server and consuming memory from tempdb. I tried to get the PID for this session id and the source server from which it was generated, I could not find the PID in source server…
Krishna508
  • 11
  • 5
-1
votes
1 answer

Having trouble to disable xp_cmdshell in C# code. any alternative to xp_cmdshell

Need help to disable xp_cmdshell from below code. what are the procedure we can to take disable xp_cmdshell. -- Add the job EXECUTE @ReturnCode = msdb.dbo.sp_add_job @job_id = @JobID OUTPUT , @job_name = N'ExportXYZPRTE', @owner_login_name =…
sid
  • 9
  • 2
-1
votes
1 answer

Headers in xp_cmdshell bcp export (SQL Server)

I can't seem to find a way to retain the column headers using xp_cmdshell bcp to export a .csv or .txt file. Currently I'm using this code to export the tables to a txt file: SET @sqlsave = 'master.sys.xp_cmdshell ''bcp "SELECT * FROM…
Lore
  • 1
  • 1
-1
votes
1 answer

Check Existing File using xp_cmdshell in SQL and return a value in cmdshell

I am trying to create a file using the SP - MSSQL. before creating a file i want to check Whether the file exist . IF Exist i want to replace a new one or else create a new file. Want to return a value while executing the cmdshell in sql. …
Manu C Rajan
  • 153
  • 1
  • 2
  • 13
-1
votes
1 answer

bcp dynamic query not accepting more than 4000 characters

While generating the XML ,I am using XP-CMDSHELL along with BCP.My query character length is more than the 4000 characters . Bcp only considering 4000 characters. kindly suggest the way. Note : query is not going to convert in sp or view
Vicky J
  • 1
  • 3
-1
votes
1 answer

using gpg2 from xp_cmdshell

I am trying to use gpg2 directly from sql to encrypt a xml file that I will be sending to an outside vendor. I can create the xml file and ftp without errors, but I am running into an issue when trying to use the gpg2 commands to encrypt the file. …
-6
votes
1 answer

How to run a batch file in xp_cmdshell

When I try to run this: exec master..xp_cmdshell 'C:\f\alert.bat' I get the following error message: 'C:\f\alert.bat' is not recognized as an internal or external command, operable program or batch file. How can I run this batch file using…
Brandon Moore
  • 8,590
  • 15
  • 65
  • 120
1 2 3
17
18