我已经构建了这个脚本并且它成功创建了数据库但它没有附加它。你知道我怎么能附上吗?
(根据评论更改MYTABLE
更改为MYDATABASE
并添加USE [MYDATASBASE]
)
USE [master]
GO
/****** Object: Database [MYDATABASE] Script Date: 5/26/2016 9:40:02 AM ******/
declare @Path as nvarchar(max)
SELECT @Path = CONVERT(nvarchar(max),SERVERPROPERTY('InstanceDefaultDataPath'))
Print (@Path)
declare @sql as nvarchar(max)
set @sql = N'CREATE DATABASE [MYDATABASE]
ON (NAME = N''MYDATABASE'',
FILENAME = N''' + @Path + 'MYDATABASE.mdf'', SIZE = 18432KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB)
LOG ON (NAME = N''MYDATABASE_log'',
FILENAME = N''' + @Path + 'MYDATABASE_1.ldf'', SIZE = 6272KB , MAXSIZE = 2048GB , FILEGROWTH = 10%) ALTER DATABASE [MYDATABASE] SET COMPATIBILITY_LEVEL = 100'
--PRINT (@sql)
EXEC(@sql)
GO
USE [MYDATABASE]
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [MYDATABASE].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [MYDATABASE] SET ANSI_NULL_DEFAULT OFF
-MORE SCHEMA AND DATA BELOW HERE…