Solved

Creating a Directory using TSQL

Posted on 2002-03-19
2
1,056 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:
ScottPletcher 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now