Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 delete XL file using xp_cmdshell in sqlserver

Author  Topic 

kond.mohan
Posting Yak Master

213 Posts

Posted - 2012-10-06 : 01:57:16

Dear team ,

we need to know the XP_CMDSHELL usage in sql server 2008 and

and how to delete XL file or other files from specified Location using xp_cmdsheel

Regards
K.Mohan

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-10-06 : 07:51:01
By default xp_cmdshell is disabled. So if you have not already enabled it, you will need to do so. See here: http://msdn.microsoft.com/en-us/library/ms190693.aspx

Once you have enabled it, the usage is pretty simple - exec xp_cmdshell 'del C:\temp\yourexcel.xlsx'.

One thing you want to be careful about is permissions and security. Read through the permissions section on this page: http://msdn.microsoft.com/en-us/library/ms175046.aspx
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-10-06 : 12:08:33
usually proxy accounts are used for executing xp_cmdshell scripts giving desired permissions to those accounts

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -