troubleshooting Question

How to delete file with using cmd xp_cmdshell if filename has space between the letter?

Avatar of erin027
erin027Flag for United States of America asked on
Microsoft SQL ServerASP
2 Comments2 Solutions789 ViewsLast Modified:
Hello,
When I created this stored procedure, I notice that when if the file name has space between the letter, it won't delete it.
How do I delete the file that has space between the letter?
of should I create a '-' when I upload the file? if so how do I do that?

Create Proc DeleteCategory (
      @CategoryImage nvarchar(100)
)
AS
SET NOCOUNT ON
--Delete the file from the server
If @CategoryImage is not Null or @CategoryImage <> ''
DECLARE @cmd nvarchar(1000)
set @cmd = ' del D:\Sites\uniquepiece\product_images\' + @categoryImage
EXEC master..xp_cmdShell @cmd
go
ASKER CERTIFIED SOLUTION
Ashish Patel

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros