I'm using Windows 7 (x64) and I have an auto generated script for creating a SQL Server Express 2012 database.
The script starts as follows:
USE [master]
GO
CREATE DATABASE [Example]
CONTAINMENT = NONE
ON PRIMARY
( NAME = N'Example', FILENAME = N'D:\Example.mdf' , SIZE = 4544KB ,
MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'Example_log', FILENAME = N'D:\Example_log.ldf' , SIZE = 3136KB ,
MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
ALTER DATABASE [Example] SET COMPATIBILITY_LEVEL = 100
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [Example].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
...
The script first error is
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near 'CONTAINMENT'.
The idea is to pass a database from one server to the other with different SQL Server 2012 versions. I wanted to keep the scripts in case I needed to create the DB somewhere else.
Why does the automatically generated script cause this error?
Syntax: CREATE DATABASE database_name; database_name: name of the database. Example Query: This query will create a new database in SQL and name the database as my_database.
To change the option settings for a databaseIn Object Explorer, connect to a Database Engine instance, expand the server, expand Databases, right-click a database, and then click Properties. In the Database Properties dialog box, click Options to access most of the configuration settings.
Use SQL Server Management StudioRight-click Databases, and then select New Database. In New Database, enter a database name. To create the database by accepting all default values, select OK; otherwise, continue with the following optional steps. To change the owner name, select (...) to select another owner.
Get rid of the CONTAINMENT = NONE
It is the default so you don't need it and SQL Server Express seems to choke on it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With