之乎者也,阿弥陀佛

软件设计的原则就是,化繁为简,化难为易,把人的思维集中在简单的领域,然后通过有序的组合实现复杂的逻辑。

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
代码
USE master;
GO
if  exists (select * from sys.databases where name = 'TestDB')
drop database TestDB

--创建文件夹
EXEC sp_configure 'show advanced options'1
GO
RECONFIGURE
GO
EXEC sp_configure 'xp_cmdshell'1
RECONFIGURE
GO
ExEc xp_cmdshell 'mkdir D:\aaa' --调用DOS命令创建project文件夹 
--
exec xp_cmdshell 'rd d:\new /s/q' --删除文件夹 
--
创建数据库
/*
*
注意:
1,FILENAME路径;
2,初始化数据库大小和增长方式
*
*/
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 )
'
);


下面是一段判断文件夹是否存在的SQL语句

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. 

代码
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


 

posted on 2010-07-27 15:15  搏击的小船  阅读(2880)  评论(0编辑  收藏  举报