Run Batch file from SQL

Hi

I'm trying to run a batch file from a SQL Script but error occurs.

Script:
EXEC xp_CMDShell 'C:\Users\Simon\Desktop\Stadium\Stadium Insert\Integration Services Project7\refresh.bat'

Error:
output
'C:\Users\Simon\Desktop\Stadium\Stadium' is not recognized as an internal or external command,
operable program or batch file.
NULL
simonraineAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tom CieslikIT EngineerCommented:
Try

"EXEC xp_CMDShell 'C:\Users\Simon\Desktop\Stadium\Stadium Insert\Integration Services Project7\refresh.bat"
since you have space in path, you must use "

or if this will not work change spaces for %20

EXEC xp_CMDShell 'C:\Users\Simon\Desktop\Stadium\Stadium%20Insert\Integration%20Services%20Project7\refresh.bat'
simonraineAuthor Commented:
hi error, using %20

: output
The system cannot find the path specified.
NULL
simonraineAuthor Commented:
moved bat file to folder with no spaces in name

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Tom is correct about the spaces being an issue, but the correct command is
EXEC xp_CMDShell ' "C:\Users\Simon\Desktop\Stadium\Stadium Insert\Integration Services Project7\refresh.bat" '

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.