Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Attach a database SQL from network drive??

Posted on 2013-06-28
5
Medium Priority
?
971 Views
Last Modified: 2013-06-28
I have a database that mdf, ldf files that are not on the local machine but on a network drive such as X. When I try to attach the databases to the server I am only seeing the local drives C and D.

Is it possible to attach a database from another network drive or does it have to reside locally?
0
Comment
Question by:Jordan_WM
5 Comments
 
LVL 11

Accepted Solution

by:
Louis01 earned 1200 total points
ID: 39284403
SSMS would not allow you through the normal attach menu option.
You'll need to script it. Something like:

USE master;
GO
CREATE DATABASE MyAdventureWorks 
    ON (FILENAME = 'C:\MySQLServer\AdventureWorks2012_Data.mdf'),
    (FILENAME = 'C:\MySQLServer\AdventureWorks2012_Log.ldf')
    FOR ATTACH;
GO

Open in new window


http://technet.microsoft.com/en-us/library/ms187858.aspx
http://blogs.msdn.com/b/varund/archive/2010/09/02/create-a-sql-server-database-on-a-network-shared-drive.aspx

Some say you shouldn't...
http://sqlrecoverydatabase.blogspot.com/2010/03/storing-sql-server-database-on-network.html?m=1
0
 
LVL 16

Expert Comment

by:EvilPostIt
ID: 39284405
Take a look at this article by Brent Ozar.
0
 

Author Closing Comment

by:Jordan_WM
ID: 39284426
Thanks for the post that was exactly what I am looking for, I needed to move the DB because I am limited to size where the instance of SQL server is running.
0
 
LVL 16

Expert Comment

by:EvilPostIt
ID: 39284499
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 39284774
Warning! You should do that only for emergency or short-term operation! At least the transaction log should always be local, the data files might then be located on a network share - again, never in a production env!
The reason is that network I/O is unreliable, and doesn't allow for the necessary force-write commands to make write operations safe.
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This collection of functions covers all the normal rounding methods of just about any numeric value.
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question