Code Use Master;
Go
If Exists ( Select * From SYS. Databases Where Name = ' Testdb ' )
Drop Database Testdb
-- Create a folder
Exec Sp_configure ' Show advanced options ' , 1
Go
Reconfigure
Go
Exec Sp_configure ' Xp_mongoshell ' , 1
Reconfigure
Go
Exec Xp_mongoshell ' Mkdir D: \ aaa ' -- Call the doscommand to create a project folder
-- Exec xp_cmdshell 'RD D: \ new/S/Q' -- delete a folder
-- Create a database
/* *
Note:
1. Filename Path;
2. initialize the database size and growth mode
* */
Execute ( ' Create Database testdb
On
(Name = testdb_dat,
Filename = '' D: \ AAA \ testdb. MDF '' ,
Size = 500,
Maxsize = unlimited,
Filegrowth = 100)
Log On
(Name = testdb_log,
Filename = '' D: \ AAA \ testdb. LDF '' ,
Size = 500,
Maxsize = unlimited,
Filegrowth = 100) '
);
The following is an SQL statement used to determine whether a folder exists.
Xp_fileexist: checks to see if a given file exists or not. it returns three columns with a value of 1 (yes) or 0 (no): file exists, file is a directory and parent directory exists.
Code Create Table # TMP ( [ File exists ] Bit , [ File is a directory ] Bit , [ Parent directory exists ] Bit )
Insert Into # TMP ( [ File exists ] , [ File is a directory ] , [ Parent directory exists ] )
Exec Master. DBO. xp_fileexist ' D: \ aaa '
Select * From # TMP
Drop Table # TMP