Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a file system directory in a SQL Server 2005 call/query

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

like image 492
Mosquito Mike Avatar asked Jun 11 '09 00:06

Mosquito Mike


People also ask

How do I create a directory in SQL query?

Step 1 : First of all you should select the respective filetable in which you need to create a folder and right click on it and select “Explore filetable directory” as shown in the image below. Step 2 : Once you select “Explore filetable directory”, it will open that particular filetable directory folder.

How do I create a directory in SQL Server script?

Create Database using SQL Server Management Studio. Open SSMS and in Object Explorer, connect to the SQL Server instance. Expand the database server instance where you want to create a database. Right-click on Databases folder and click on New Database..


1 Answers

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

like image 68
Tetraneutron Avatar answered Oct 20 '22 01:10

Tetraneutron