tthrone
3/15/2007 7:36:00 PM
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.
>