Database creation

  • Hi All,

    I am pretty new to SQL Server 2008 and i got stuck while creating a new database which includes a primary filegroup and user defined filegroup as well as to create a log file. My syntax goes like this.

    CREATE DATABASE SQL2008SBS ON PRIMARY

    ( NAME = 'SQL2008SBS', FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\SQL2008SBS.mdf',

    SIZE = 3MB , MAXSIZE = UNLIMITED, FILEGROWTH = 10%),

    FILEGROUP FG1 DEFAULT ( NAME = 'SQL2008SBSFG1_Dat1' ,

    FILENAME = 'C: \Program Files\Microsoft SQL Server\MSSQL10. MSSQLSERVER\MSSQL\DATA\SQL2008SBS_1.ndf' ,

    SIZE = 2MB , MAXSIZE = UNLIMITED, FILEGROWTH = 2MB) ,

    (NAME = 'SQL2008SBSFG1_Dat2' , FILENAME = 'C: \Program Files\Microsoft SQL Server\MSSQL10. MSSQLSERVER\MSSQL\DATA\SQL2008SBS_2. ndf' ,

    SIZE = 2MB , MAXSIZE = UNLIMITED, FILEGROWTH = 2MB) ,

    (NAME = 'SQL2008SBSFG1_Dat3' , FILENAME = 'C: \Program Files\Microsoft SQL Server\MSSQL10. MSSQLSERVER\MSSQL\DATA\SQL2008SBS_3. ndf' ,

    SIZE = 2MB , MAXSIZE = UNLIMITED, FILEGROWTH = 2MB)

    LOG ON ( NAME = 'SQL2008SBS_Log', FILENAME = 'C: \Program Files Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\SQL2008SBS.ldf' ,

    SIZE = 2MB , MAXSIZE = UNLIMITED , FILEGROWTH = 10MB )

    GO

    However i get the following error when i am trying to execute the above code. I know that this can be done graphically too but i wanted to do it the SQL Command way. Somone please help me. Thanks in advance.

    Msg 5105, Level 16, State 2, Line 1

    A file activation error occurred. The physical file name 'C: \Program Files\Microsoft SQL Server\MSSQL10. MSSQLSERVER\MSSQL\DATA\SQL2008SBS_1.mdf' may be incorrect. Diagnose and correct additional errors, and retry the operation.

    Msg 1802, Level 16, State 1, Line 1

    CREATE DATABASE failed. Some file names listed could not be created. Check related errors.

  • There's a space in some of your file names.

    C: \Program Files\Microsoft SQL Server\MSSQL10. MSSQLSERVER\MSSQL\DATA

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • If you have spaces in the filename you can use it like this : FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\AdventureWorks_Data.mdf'

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply