Having Trouble with first SQL 2012 Database

  • Just moved from learning mysql to SQL Server 2012, and already having an issue.

    Here is my code:

    CREATE DATABASE ApressFinancial ON PRIMARY

    ( Name = N' ApressFinancial ',

    FILENAME = N' C:\Program Files\Microsft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\APRESSFINANCIAL.mdf' ,

    SIZE = 4096KB ,

    MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )

    LOG ON

    ( NAME= N'ApressFinancial_log',

    FILENAME= N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\APRESSFINANCIAL_log.ldf' ,

    SIZE = 1024KB, MAXSIZE = 2048GB, FILEGROWTH = 10%)

    COLLATE SQL_LATIN1_General_CP1_CI_AS

    GO

    Here is my error

    Msg 5105, Level 16, State 2, Line 1

    A file activation error occurred. The physical file name ' C:\Program Files\Microsft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\APRESSFINANCIAL.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.

  • Looks like a typo in your file path

    CREATE DATABASE ApressFinancial ON PRIMARY (

    Name = N' ApressFinancial ',

    FILENAME = N' C:\Program Files\Microsft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\APRESSFINANCIAL.mdf' ,

    SIZE = 4096KB ,

    MAXSIZE = UNLIMITED,

    FILEGROWTH = 1024KB )

    LOG ON (

    NAME= N'ApressFinancial_log',

    FILENAME= N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\APRESSFINANCIAL_log.ldf' ,

    SIZE = 1024KB,

    MAXSIZE = 2048GB,

    FILEGROWTH = 10%)

    COLLATE SQL_LATIN1_General_CP1_CI_AS

    "Microsft SQL Server" is missing an "o"

  • wow. I'm an idiot. Thank you so much

  • No worries, it happens to all of us at some point 🙂

    Also, here are a couple of newbie-unfriendly defaults that you may wish to change:

    1. Please consider moving the database to somewhere other than the C: drive if at all possible

    2. Either set the database Recovery Model to Simple, or set up regular transaction log backups

  • Ah ok I thought it would be best to start practicing with full recovery as in a production environment but I get your point starting out.

  • Just tried it again.

    Msg 5105, Level 16, State 2, Line 1

    A file activation error occurred. The physical file name ' C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\APRESSFINANCIAL.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.

    Does it have anything to do with the whole sql server folder being read only?

  • anyone?

  • You've got a space before C:. ' C:\' chould be 'C:\' Directories never have a space at the beginning

    btw, we're all volunteers here, we all post in our spare time, we don't work for SSC.

    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
  • Oh I know don't mistake my impatience for arrogance or whatever. You guys are amazing helpers. I just was getting really frustrated. And it worked so you've done me a great favor. I need to learn how to really look at the syntax, I just hope it's rookie mistakes.

  • This may be a stupid question but everytime I make a new command or query with T-SQL, do I have to open up a new query window or can I just delete the previous query and type in the blank of said query?

  • bump

  • dob111283 (4/12/2013)


    This may be a stupid question but everytime I make a new command or query with T-SQL, do I have to open up a new query window or can I just delete the previous query and type in the blank of said query?

    No, you don't have to open a new query window. You don't even have to delete what is already in the current window. You can type a new query, hightlight it and execute it. I do it all the time. Sometimes I'll also comment previous code so I don't have to highlight just the code I want. I usually do this when I need the code in the query window for things I am working on.

  • dob111283 (4/15/2013)


    bump

    At this point, my recommendation is to press the {f1} key and begin reading Books Online for answers to some of these questions. It will not only help you now, but you'll become more familiar with it each time you use it and you'll be able to find much more complicated things in the future without resorting to "Bumps". 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Thank you for both answers. I'll work on it.

Viewing 14 posts - 1 through 13 (of 13 total)

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