[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.sqlserver.programming

Space between the folder names when executing xp_cmdshell

MittyKom

3/15/2007 2:00:00 PM

Hi All

How do you would handle the space between the folder name "Default Site" on
the below SQL as it is part of the pathname to file DB20070314 to be deleted?
I am getting the error that the path to the file is wrong?

---------
declare @nqly nvarchar (356),@date char(10)
select @date=substring(convert(char(10),getdate(),111),1,4)+
substring(convert(char(10),getdate(),111),6,2)+
substring(convert(char(10),getdate(),111),9,2)

select @nqly='master..xp_cmdshell '+'''del C:\Default
Site\DB'+rtrim(@date)+''''
--select @nqly
execute sp_executesql @nqly
--------------

I tried the below:
1. select @nqly='master..xp_cmdshell '+'''del C:\Default
Site\DB'+rtrim(@date)+''''
2. select @nqly='master..xp_cmdshell '+'''del C:\[Default
Site]\DB'+rtrim(@date)+''''

If i put the file to the folder above 'Default Site' folder, i dont get the
error when deleting. Thank you in advance.

2 Answers

tthrone

3/15/2007 7:36:00 PM

0

You need to embed quotes around the file path/name.
It's hard to see with this font, but I put a quote (") in front of your path
and a quote between two apostrophes (like this '"') at the end of your file
path.
Try this:

declare @nqly nvarchar (356),@date char(10)
select @date=substring(convert(char(10),getdate(),111),1,4)+
substring(convert(char(10),getdate(),111),6,2)+
substring(convert(char(10),getdate(),111),9,2)

select @nqly='master..xp_cmdshell '+'''del "C:\Default
Site\DB'+rtrim(@date)+'"'+''''
--select @nqly
execute sp_executesql @nqly

"MittyKom" wrote:

> Hi All
>
> How do you would handle the space between the folder name "Default Site" on
> the below SQL as it is part of the pathname to file DB20070314 to be deleted?
> I am getting the error that the path to the file is wrong?
>
> ---------
> declare @nqly nvarchar (356),@date char(10)
> select @date=substring(convert(char(10),getdate(),111),1,4)+
> substring(convert(char(10),getdate(),111),6,2)+
> substring(convert(char(10),getdate(),111),9,2)
>
> select @nqly='master..xp_cmdshell '+'''del C:\Default
> Site\DB'+rtrim(@date)+''''
> --select @nqly
> execute sp_executesql @nqly
> --------------
>
> I tried the below:
> 1. select @nqly='master..xp_cmdshell '+'''del C:\Default
> Site\DB'+rtrim(@date)+''''
> 2. select @nqly='master..xp_cmdshell '+'''del C:\[Default
> Site]\DB'+rtrim(@date)+''''
>
> If i put the file to the folder above 'Default Site' folder, i dont get the
> error when deleting. Thank you in advance.
>

Rich Rostrom

7/30/2014 3:21:00 AM

0

Paul F Austin <pfaustin@bellsouth.net> wrote:

> The Glorious Revolution was more a coup than anything else. Little
> changed except for the ruling house.

1) It didn't change the ruling House. William
ruled as a Stuart scion (and Mary was certainly
a Stuart).

2) It re-established, with great force, the
supremacy of Parliament over the Crown.

3) It changed the monarch, and thus the entire
policy of the government - i.e. ending James'
promotion of Catholics and Romanization of the
Church.
--
The real Velvet Revolution - and the would-be hijacker.

http://originalvelvetrevo...