Solved

deleting a file with SQL xp_cmdshell

Posted on 2014-09-24
3
163 Views
Last Modified: 2014-09-24
Hello experts,

I am running this one line code on SQL Management Console and it gets hung at 'Executing Query':

exec master..xp_cmdshell 'C:\Test1\Test2\test3.txt'

What is the issue? I login to the SQL Server as the local administrator of that (same) server. Is there something I am missing? Should the folder be shared instead and I use the share name?

Thank you in advance
0
Comment
Question by:bozer
  • 2
3 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 40340987
>exec master..xp_cmdshell 'C:\Test1\Test2\test3.txt'
this would only "open" the file (on the server, in the sql server login session, so unvisible except in the task manager)

to DELETE the file:


exec master..xp_cmdshell 'del C:\Test1\Test2\test3.txt'
0
 

Author Comment

by:bozer
ID: 40340990
I've requested that this question be deleted for the following reason:

Typo
0
 

Author Closing Comment

by:bozer
ID: 40340991
I just realized that after posting but you were even faster to reply Guy, thanks :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now