Use master
go
If Exists (Select * From sysdatabases Where name = 'bbs') --检查是否以存在bbsDB数据库
Drop Database bbs
go
/*---- 创建文件夹 ----*/
--sql 2005如何使用被禁止的"xp_cmdshell"
USE master
EXEC sp_configure 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
EXEC sp_configure 'xp_cmdshell', 1
RECONFIGURE WITH OVERRIDE
EXEC sp_configure 'show advanced options', 0
go
Exec xp_cmdshell 'mkdir D:/bbsDB'
go
/*------ 建库 ------*/
Create Database bbs
on
(
/*-------- 数据文件具体描述 ----------*/
'bbs_data', --主数据文件的逻辑名称
'D:/bbsDB/bbs_data.mdf', --数据文件的物理名称
Size = 5Mb, -- 主数据文件的初始大小
FileGrowth = 20% --主数据文件增长率
)
log on
(
/* ------ 日志文件的具体描述,各参数含义同上 ------ */
'bbs_log',
'd:/bbsDB/bbs_log.ldf',
Size = 3Mb,
FileGrowth = 10%
)
go
-----------------------------------------------
/*--- 创建表 ---*/
Use bbs
go
/* --- 检查是否存在表TBL_USER ---*/
If Exists (Select * From Sysobjects where name = 'TBL_USER')
Drop Table TBL_USER
Create Table TBL_USER
(
int
null,
null,
null,
null,
null
)
go