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
1
vote
3 answers

SQL Server xp_cmdshell error 5

When I execute the following statement in SQL Server 2008: declare @s varchar(100) set @s='dir' exec sp_configure 'show advanced options',1 reconfigure exec sp_configure 'xp_cmdshell',1 reconfigure exec xp_cmdshell @s It gives the following error:…
Dolphin
  • 29,069
  • 61
  • 260
  • 539
1
vote
1 answer

Could not load file or assembly 'System.Data.DataSetExtensions, Version=3.5.0.0

I have a C# Console Application that uses System.Data.DataSetExtensions that I can run smoothly on the client's server through the command line. The only thing I did was to copy the bin/Release directory contents to a specific directory on the…
1
vote
2 answers

BCP Parameter issues

I Hope I'm not re-asking.. but.. here's the pertinent section of my SQL. The view in question (vw_TempALlItems) is created in prior steps, and yes its created using column names, and paying attention to types & etc.. The view works 100%.. But the…
Mike D
  • 159
  • 1
  • 1
  • 13
1
vote
3 answers

T SQL multi thread for launching xp_cmdshell jobs

I have a job that takes database backup files and compresses them to .7z files using seven zips command line utility and at the moment it takes about 8 hours to run through all the .bak files because it is doing one at a time. This is running on has…
user802599
  • 787
  • 2
  • 12
  • 35
1
vote
1 answer

xp_cmdshell Proxy not Executing

I created a Proxy account with Sysadmin access. Users use this to execute a bcp command of their choosing. However when the users want's to execute the proc they get: EXECUTE permission was denied on the object 'xp_cmdshell', database…
Jacques Bronkhorst
  • 1,685
  • 6
  • 34
  • 64
1
vote
2 answers

xp_cmdshell error "The filename, directory name, or volume label syntax is incorrect."

I am just in the midst of deploying some code to production, which is an upgrade of a system from SQL 2000 to SQL 2008. I'm having a mysterious problem in one of my stored procedures that fetches some data from the database, then creates some files…
jazza1000
  • 4,099
  • 3
  • 44
  • 65
1
vote
1 answer

Calling xp_cmdshell from a Stored Procedure

As a proof of concept we're trying to insert an xp_cmdshell command into an existing solution. Currently an application invokes a stored procedure on our database server which when profiled looks like: declare @P1 int set @P1=1 exec…
Paul
  • 1,041
  • 11
  • 26
1
vote
1 answer

Why do I get an error with sql cmdshell when it works in the actual shell?

I run the following: EXEC XP_CMDSHELL 'fsutil fsinfo volumeinfo C:' returns Error: The filename, directory name, or volume label syntax is incorrect. NULL NULL However, hitting the D: drive works just fine. Also if I just run fsutil…
AngryHacker
  • 59,598
  • 102
  • 325
  • 594
1
vote
1 answer

xp_cmdshell proxy account disabled Automatically

when i want to execute xp_cmdshell sp is sql server it give me error that I don't have permission to run xp_cmdshell. when i check in security tab in Property window of instance,in the service Proxy Account section enable service account Proxy check…
1
vote
3 answers

using BCP to export stored procedure result in SQL Server 2008

Heyy, I'm trying to use BCP to export a SP result to a text file using this query: EXEC xp_cmdshell 'bcp "exec asmary..usp_Contract_SelectByEmpId -1,1" queryout "C:\test.txt" -w -C OEM -t$ -T -r ~ -S heba\HEBADREAMNET ' The output of this query is…
Heba Gomaah
  • 1,145
  • 4
  • 11
  • 16
1
vote
2 answers

xp_cmdshell Query Length Too Large

All, I need to write a data set from a large SQL table to a .txt file. To do this I have chosen to use xp_cmdshell. The query I have been using to create the Data.txt file is declare @sql varchar(8000) select @sql = 'bcp "SELECT /*Lots of field…
MoonKnight
  • 23,214
  • 40
  • 145
  • 277
1
vote
1 answer

How to write a trigger firing when someone made specific changes and saved on SQL Server

I am new to SQL triggers scripting. Right now, I want to write a trigger firing when someone modify a create or alter statement in table definition in SQL Server and saved. Can someone please tell me what can make this happen and what kind of…
Joshua H.
  • 537
  • 3
  • 9
  • 19
1
vote
1 answer

Execute commands within tsql

How can I execute system command like dir other than xp_cmdshell?
seeker
  • 3,255
  • 7
  • 36
  • 68
1
vote
1 answer

Timeout on DTEXEC execution - but only when called from stored procedure

The following issue has been bugging me for a while: I have a dtsx-package for handling some interfacing. I call it in a stored procedure as seen below: SET @v_statement = 'DTEXEC /FILE "' + @v_if_ssis_package + '" /SET…
Jens
  • 3,249
  • 2
  • 25
  • 42
0
votes
1 answer

The image file is not generating properly in SQL server 2008 using xp_cmdshell

Please help me out to resolve this issue, I tried several options but unable to get success till now, any help would be greately apprecaited. I am generating one image file using xp_cmdshell on SQL Server 2008, the image is not getting generated in…