DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Data Engineering
  3. Databases
  4. LocalDB Using SQL Server Management Studio 2012 (SSMS)

LocalDB Using SQL Server Management Studio 2012 (SSMS)

Adam Hoffman user avatar by
Adam Hoffman
·
Aug. 26, 12 · Interview
Like (0)
Save
Tweet
Share
13.26K Views

Join the DZone community and get the full member experience.

Join For Free

ok, in the previous post we determined how we could attach to localdb using ssms 2012. next stop, creating a database. turns out that it's potentially harder than it seems at first.

now that i've gotten connected, i went to try to create a database. right click on the connection, create new database. fill in the name, press ok.

boom. errors like the following:

title: microsoft sql server management studio
------------------------------

create failed for database 'test'.  (microsoft.sqlserver.smo)

for help, click: http://go.microsoft.com/fwlink?prodname=microsoft+sql+server&prodver=11.0.2100.60+((sql11_rtm).120210-1846+)&evtsrc=microsoft.sqlserver.management.smo.exceptiontemplates.failedoperationexceptiontext&evtid=create+database&linkid=20476

------------------------------
additional information:

an exception occurred while executing a transact-sql statement or batch. (microsoft.sqlserver.connectioninfo)

------------------------------

a file activation error occurred. the physical file name 'test.mdf' may be incorrect. diagnose and correct additional errors, and retry the operation.
create database failed. some file names listed could not be created. check related errors. (microsoft sql server, error: 5105)

for help, click: http://go.microsoft.com/fwlink?prodname=microsoft%20sql%20server&prodver=11.00.2100&evtsrc=mssqlserver&evtid=5105&linkid=20476

------------------------------
buttons:

ok
------------------------------

... and digging into the details, looks like the following:

===================================

create failed for database 'test'.  (microsoft.sqlserver.smo)

------------------------------
for help, click: http://go.microsoft.com/fwlink?prodname=microsoft+sql+server&prodver=11.0.2100.60+((sql11_rtm).120210-1846+)&evtsrc=microsoft.sqlserver.management.smo.exceptiontemplates.failedoperationexceptiontext&evtid=create+database&linkid=20476

------------------------------
program location:

   at microsoft.sqlserver.management.smo.sqlsmoobject.createimpl()
   at microsoft.sqlserver.management.sqlmanagerui.createdatabasedata.databaseprototype.applychanges(control marshallingcontrol)
   at microsoft.sqlserver.management.sqlmanagerui.createdatabase.dopreprocessexecution(runtype runtype, executionmode& executionresult)
   at microsoft.sqlserver.management.sqlmgmt.sqlmgmttreeviewcontrol.dopreprocessexecutionandrunviews(runtype runtype)
   at microsoft.sqlserver.management.sqlmgmt.sqlmgmttreeviewcontrol.executeforsql(preprocessexecutioninfo executioninfo, executionmode& executionresult)
   at microsoft.sqlserver.management.sqlmgmt.sqlmgmttreeviewcontrol.microsoft.sqlserver.management.sqlmgmt.iexecutionawaresqlcontrolcollection.preprocessexecution(preprocessexecutioninfo executioninfo, executionmode& executionresult)
   at microsoft.sqlserver.management.sqlmgmt.viewswitchercontrolsmanager.runnow(runtype runtype, object sender)

===================================

an exception occurred while executing a transact-sql statement or batch. (microsoft.sqlserver.connectioninfo)

------------------------------
program location:

   at microsoft.sqlserver.management.common.serverconnection.executenonquery(string sqlcommand, executiontypes executiontype)
   at microsoft.sqlserver.management.common.serverconnection.executenonquery(stringcollection sqlcommands, executiontypes executiontype)
   at microsoft.sqlserver.management.smo.executionmanager.executenonquery(stringcollection queries)
   at microsoft.sqlserver.management.smo.sqlsmoobject.executenonquery(stringcollection queries, boolean includedbcontext)
   at microsoft.sqlserver.management.smo.sqlsmoobject.createimplfinish(stringcollection createquery, scriptingpreferences sp)
   at microsoft.sqlserver.management.smo.sqlsmoobject.createimpl()

===================================

a file activation error occurred. the physical file name 'test.mdf' may be incorrect. diagnose and correct additional errors, and retry the operation.
create database failed. some file names listed could not be created. check related errors. (.net sqlclient data provider)

------------------------------
for help, click: http://go.microsoft.com/fwlink?prodname=microsoft%20sql%20server&prodver=11.00.2100&evtsrc=mssqlserver&evtid=5105&linkid=20476

------------------------------
server name: (localdb)\v11.0
error number: 5105
severity: 16
state: 2
line number: 1


------------------------------
program location:

   at microsoft.sqlserver.management.common.connectionmanager.executetsql(executetsqlaction action, object execobject, dataset filldataset, boolean catchexception)
   at microsoft.sqlserver.management.common.serverconnection.executenonquery(string sqlcommand, executiontypes exe

so what's going on here? i open up a query window, type the following and run it:

create database [test]
go

that works fine? what gives?

rooting around the file system a bit gives the answer. when creating a database via ddl script, like this, the default output directory is "c:\users\adam" (yours will be your name, of course), and the database files end up in that directory. looking at my drive, i now see test.mdf and test_log.mdf in that directory. however, looking at where ssms wants to create them reveals the problem. in the database files section of the general page in the new database dialog, scroll over to the right and have a look at the path location. it's set to <default path> . now click on the dot-dot-dot (ellipsis) and take a look at what that default path is...

c:\users\adam\appdata\local\microsoft\microsoft sql server local db\instances\v11.0

that's not gonna work, and besides, i'd never find the mdf file again if i put it in there.

so, change that path to "c:\users\adam" in the create database dialog fixes the problem, or just use the "create database" ddl instead.

Database sql

Published at DZone with permission of Adam Hoffman, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Why It Is Important To Have an Ownership as a DevOps Engineer
  • How to Secure Your CI/CD Pipeline
  • How To Use Terraform to Provision an AWS EC2 Instance
  • Distributed SQL: An Alternative to Database Sharding

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: