Main |
How to Create a Directory (Folder)
...by Siccolo...
Engineered to help you extend your support from mobile devices for Microsoft SQL Servers, Siccolo mobile management tool is a portable administration tool for Microsoft SQL Server.
Siccolo is the premier GUI admin tool for Microsoft SQL Server management, control and development.
Siccolo gives you wide opportunities to perform all the necessary database admin
routines such as creating, editing, dropping database objects;
moreover, you can build queries, execute queries and SQL scripts,
view data, export data, manage SQL Server users and their privileges,
add jobs and alerts, and use a lot of other admin tools implemented to
make your work with SQL Server highly enjoyable and efficient.
If you need the job done right and on time, do it with Siccolo on your team.
Siccolo provides you with a number of easy-to-use features for performing the required data manipulation
and server management easily and quickly.
|
|
In many cases you a have a need retrieve certain path locations related to the SQL Server
you are connected to, like the directory where SQL Server is installed in,
the default data and log directory or back directory.
|
|
Using xp_cmdshell -
eXtended stored procedure provided by Microsoft and stored in the master database.
This procedure allows you to issue operating system commands directly to the Windows command shell via T-SQL code.
If needed the output of these commands will be returned to the calling routine.
create procedure sp_create_directory
(
@full_path varchar(500)
)
as
set nocount on
declare @command varchar(1000)
set @command = 'mkdir ' + @full_path
exec master..xp_cmdshell @command , no_output
set nocount off
GO
Side Note:
xp_cmdshell - eXtended SQL stored procedure.
Executes a given command string as an operating-system command shell and returns any output as rows of text. Grants nonadministrative users permissions to execute xp_cmdshell.
xp_cmdshell operates synchronously. Control is not returned until the command shell command completes.
Where xp_cmdshell {'command_string'} [, no_output]
For example, to retireve all the folders for a given disk path:
create table #tmp (directory_name varchar(255))
insert into #tmp
exec master.dbo.xp_cmdshell "dir d:\ /B /A:D /S"
select * from #tmp --for xml auto
drop table #tmp
or to get server information:
exec master.dbo.xp_cmdshell "net statistics server"
|
|