PDA

View Full Version : SQL Script to create Database Fails



majorburner
07-06-2006, 04:29 AM
OK, i try to create a Database with a SQL Script.

Here is some of the code


USE [master]
GO
IF NOT EXISTS (SELECT name FROM sys.databases WHERE name = N'Openit')
BEGIN
CREATE DATABASE [Openit] ON PRIMARY
( NAME = N'Openit', FILENAME = N'*Datadir*Openit.mdf' , SIZE = 4096000KB , MAXSIZE = UNLIMITED, FILEGROWTH = 10%)
LOG ON
( NAME = N'Openit_log', FILENAME = N'*Datadir*Openit_log.ldf' , SIZE = 2048000KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
END

Where *Datadir* will be replaced with the path to store the datafiles in.

However this script runs without errors.
But:
a) The databse files are created in the standard Database Folder (D:\Microsoft SQL Server\MSSQL.1\MSSQL\Data)

b) The filesize is 500k or something and not 4GB and 2GB as specified in the script

This script works fine from the Query Analyzer.

Thank you very much in advance

majorburner
07-06-2006, 07:49 AM
ok,

i just found out i had "Create Catalog if Absent" in my SQL Connection activated.

The Catalog Name was the same as the Database to create, so i guess this did already create the databse for me at the default location.