Solved

Creating a Directory using TSQL

Posted on 2002-03-19
2
1,059 Views
Last Modified: 2012-06-27
Hello all,

  Looking for the syntax to create a folder\directory on a Sql Servers hard drive for a backup to be stored in, this is a query that will be run once, creating a backup into a d:\tempbackup  directory, to then be restored as another database, then the .bak file deleted and the tempbackup directory removed also. I have the query all set up except getting sql server to somehow create the directory,can anyone help????

Regards
Chowster
0
Comment
Question by:Chowster
2 Comments
 
LVL 69

Accepted Solution

by:
Scott Pletcher earned 100 total points
ID: 6880645
Have you tried xp_cmdshell?  Maybe something like this:

EXEC master..xp_cmdshell 'MD d:\parent1\parent2\newdirec'

where d: is the appropriate drive letter on your system.  Not sure if this will work, but it may be worth a try.
0
 

Author Comment

by:Chowster
ID: 6880786
Already found this out, but triedto delete the question but as For some reason it has not deleted I will give you the ponts,

Many thanks for the speedy response.

Chowster
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question