Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CONTAINMENT is marked as incorrect syntax on auto-generated database script

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?

like image 496
Pimenta Avatar asked Mar 14 '13 12:03

Pimenta


People also ask

What will be the correct query to create database?

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.

How do I change SQL Server database settings?

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.

How can create query in SQL Server database?

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.


1 Answers

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.

like image 55
Sebastian Meine Avatar answered Oct 25 '22 08:10

Sebastian Meine