SQLSERVER快速建库脚本
MSSqlServer 快速建库脚本 JerryTienCN
①建库
-- 搜索 [Sharp4DemoDase]
-- 更改为你要创建的库名称
-- 搜索 N'Sharp4DBTest_log'
-- 替换为新库的日志名称
-- 搜索 N'Sharp4DBTest'
-- 替换为新的库文件名
-- 搜索 N'D:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\DATA\Sharp4DBTest.mdf'
-- 为新的库文件保存路径 '
-- 搜索 N'D:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\DATA\Sharp4DBTest_log.ldf'
-- 为新的日文件保存路途径
-- 然后执行下面的脚本
USE [master]
GO
/****** 对象 : Database [Sharp4DemoDase] 脚本日期 : 12/28/2008 23:13:57 ******/
CREATE DATABASE [Sharp4DemoDase] ON PRIMARY
( NAME = N'Sharp4DBTest' , FILENAME = N'D:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\DATA\Sharp4DBTest.mdf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'Sharp4DBTest_log' , FILENAME = N'D:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\DATA\Sharp4DBTest_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
COLLATE Chinese_PRC_CI_AS
GO
EXEC dbo. sp_dbcmptlevel @dbname= N'Sharp4DemoDase' , @new_cmptlevel= 90
GO
IF ( 1 = FULLTEXTSERVICEPROPERTY ( 'IsFullTextInstalled' ))
begin
EXEC [Sharp4DemoDase]. [dbo]. [sp_fulltext_database] @action = 'disable'
end
GO
ALTER DATABASE [Sharp4DemoDase] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [Sharp4DemoDase] SET ANSI_NULLS OFF
GO
ALTER DATABASE [Sharp4DemoDase] SET ANSI_PADDING OFF
GO
ALTER DATABASE [Sharp4DemoDase] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [Sharp4DemoDase] SET ARITHABORT OFF
GO
ALTER DATABASE [Sharp4DemoDase] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [Sharp4DemoDase] SET AUTO_CREATE_STATISTICS ON
GO
ALTER DATABASE [Sharp4DemoDase] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [Sharp4DemoDase] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [Sharp4DemoDase] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [Sharp4DemoDase] SET CURSOR_DEFAULT GLOBAL
GO
ALTER DATABASE [Sharp4DemoDase] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [Sharp4DemoDase] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [Sharp4DemoDase] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [Sharp4DemoDase] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [Sharp4DemoDase] SET ENABLE_BROKER
GO
ALTER DATABASE [Sharp4DemoDase] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [Sharp4DemoDase] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [Sharp4DemoDase] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [Sharp4DemoDase] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [Sharp4DemoDase] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [Sharp4DemoDase] SET READ_WRITE
GO
ALTER DATABASE [Sharp4DemoDase] SET RECOVERY FULL
GO
ALTER DATABASE [Sharp4DemoDase] SET MULTI_USER
GO
ALTER DATABASE [Sharp4DemoDase] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [Sharp4DemoDase] SET DB_CHAINING OFF
②删库
USE [master]
GO
/****** 对象 : Database [Test01] 脚本日期 : 12/29/2008 10:08:46 ******/
IF EXISTS ( SELECT name FROM sys.databases WHERE name = N'Test01' )
DROP DATABASE [Test01]