11

I need to create a directory for sql server backups. I have to dynamically place the backup file in different folders on many different sql server installs. The backup fails if the directory doesn't exist. So if I can create the directory in a stored procedure or some other call before I call the backup command that would be helpful. Any ideas?

Thanks

1 Answer 1

27

Try

declare @Path varchar(100)
set @Path = 'c:\CreatedFromSQL'
EXEC master.dbo.xp_create_subdir @Path

Sourced from http://www.mssqltips.com/tip.asp?tip=1460

Sign up to request clarification or add additional context in comments.

2 Comments

You mark it as the selected answer by clicking the "Tick" below the Vote counter in my answer.
I tried this very same code, and can't find a "CreatedFromSql" folder anywhere in C:\. What should I do?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.