﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Discuss Content Posted by Chris Kempster / Article Discussions / Article Discussions by Author  / Quickly Moving Databases / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 24 May 2012 14:03:40 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Quickly Moving Databases</title><link>http://www.sqlservercentral.com/Forums/Topic3193-75-1.aspx</link><description>Is there any risk in using sp_detach in production database? I would like to move some of my data file in different array partition to have more disk space. I'm just worried about the uncommitted transaction in my production database. If i have a downtime schedule let say tomorrow at 8:00 am then i detach my database at 8:30 am. What will happen to the transactions? Is the sp_detach will not delete the uncomitted transcation then this will comit after sp_attach? i know the transaction is in logs, I just want to make sure that i will not do anything wrong in my data.Thanks for the expert advice.</description><pubDate>Tue, 12 Jan 2010 23:57:14 GMT</pubDate><dc:creator>arnold-491793</dc:creator></item><item><title>RE: Quickly Moving Databases</title><link>http://www.sqlservercentral.com/Forums/Topic3193-75-1.aspx</link><description>Is that more than 16 data files? Or is it with log files?sp_attach_db has hardcoded 16 file limit because of the parameters. Look at the code. If you're doing more than that, someone must have modified your procedure.</description><pubDate>Fri, 08 Feb 2008 07:25:22 GMT</pubDate><dc:creator>Steve Jones - SSC Editor</dc:creator></item><item><title>RE: Quickly Moving Databases</title><link>http://www.sqlservercentral.com/Forums/Topic3193-75-1.aspx</link><description>BOL 2000"sp_attach_db should only be executed on databases that were previously detached from the database server using an explicit sp_detach_db operation. If more than 16 files must be specified, use CREATE DATABASE with the FOR ATTACH clause."</description><pubDate>Fri, 08 Feb 2008 06:49:40 GMT</pubDate><dc:creator>RichB</dc:creator></item><item><title>RE: Quickly Moving Databases</title><link>http://www.sqlservercentral.com/Forums/Topic3193-75-1.aspx</link><description>[b]THIS STATEMENT IS NOT TRUE:[/b]  "You should note that you cannot re-attach more than 16 files for a single database"I regularly attach our databases that are 4TB in size and have 25 files!!!   :w00t:</description><pubDate>Fri, 08 Feb 2008 06:25:58 GMT</pubDate><dc:creator>cgunner</dc:creator></item><item><title>RE: Quickly Moving Databases</title><link>http://www.sqlservercentral.com/Forums/Topic3193-75-1.aspx</link><description>Good article but not practical for many environments. Like some other posters mentioned I think backup/restore should have been mentioned but with a slight twist. We use Litespeed to speed up and compress backups (faster copying) if your employer won't pony up the bucks , I think you can grab a free copy of SQL Safe from Idera which will give the same result. (more or less)For larger databases working with a compressed backup can be faster than any of the methods mentioned above.Cheers.Chris.</description><pubDate>Fri, 08 Feb 2008 05:37:12 GMT</pubDate><dc:creator>Chris_P</dc:creator></item><item><title>RE: Quickly Moving Databases</title><link>http://www.sqlservercentral.com/Forums/Topic3193-75-1.aspx</link><description>Try looking at create database for attach.You cant restore a database with the same name as an existing database - but you can restore it with a different name, apply the transaction logs, stop connections to the original, backup its tlog and apply that to the new one, then rename both.  Which if you get right would only be a couple of seconds.One caveat to detaching databases to move them - Logshipped databases dont seem to like this - if you attach a standby database it seems to get fully recovered.  Less than ideal.  Anyone know a way around that?</description><pubDate>Fri, 08 Feb 2008 03:42:32 GMT</pubDate><dc:creator>RichB</dc:creator></item><item><title>RE: Quickly Moving Databases</title><link>http://www.sqlservercentral.com/Forums/Topic3193-75-1.aspx</link><description>I wonder if the same methods can be applied to move an OLAP database. I have a task to move an OLAP database from the "processing" server to the "production" server. If so what is the Sql code to move the OLAP database. Thanks.</description><pubDate>Fri, 08 Feb 2008 00:16:34 GMT</pubDate><dc:creator>Paul Mak-346751</dc:creator></item><item><title>RE: Quickly Moving Databases</title><link>http://www.sqlservercentral.com/Forums/Topic3193-75-1.aspx</link><description>&lt;P&gt;I tried this but it does not work... any ideas?&lt;/P&gt;&lt;P&gt;exec sp_attach_single_file_db N'MyxxDb' , N'E:\SQLServerData\MSSQL\Data\xx_Data.MDF'&lt;/P&gt;&lt;P&gt;I got the error and the log file is not created...&lt;/P&gt;&lt;P&gt;I tried also:&lt;/P&gt;&lt;P&gt;EXEC sp_attach_single_file_db @dbname = N'Altiris',   @physname = N'E:\AeXNS_Data.mdf'&lt;/P&gt;&lt;P&gt;EXEC sp_attach_db @dbname = N'AeXNS_Data',    @filename1 = N'E:\AeXNS_Data.mdf',   @Filename2 = N'F:\AeXNS_Log.LDF'&lt;/P&gt;&lt;P&gt;nothing is working...&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description><pubDate>Fri, 08 Sep 2006 13:58:00 GMT</pubDate><dc:creator>Dominique DUCHEMIN</dc:creator></item><item><title>RE: Quickly Moving Databases</title><link>http://www.sqlservercentral.com/Forums/Topic3193-75-1.aspx</link><description>&lt;P&gt;This statement is in correct:&lt;/P&gt;&lt;P&gt;"You should note that you cannot re-attach more than 16 files for a single database."&lt;/P&gt;&lt;P&gt;I routinely re-attach databases with 25 files.&lt;/P&gt;</description><pubDate>Mon, 31 Jul 2006 07:23:00 GMT</pubDate><dc:creator>cgunner</dc:creator></item><item><title>RE: Quickly Moving Databases</title><link>http://www.sqlservercentral.com/Forums/Topic3193-75-1.aspx</link><description>&lt;P&gt;OK, I"m no SQL expert, but I've been tapped by my company to move our CRM SQL database from a primary to a secondary partition on the same server. I've read about detach and attach, which looks pretty simple, and I've successfully done it with a test database. Now I'm reading the posts about backup and restore to a new location, which I've also tried, however when I try to do the restore I get an error message about the database being in use and I have to take it offline in order to complete the restore. So it appears to me that the backup and restore method DOES require down-time. Can anyone clarify and honestly tell me what the best method is?&lt;/P&gt;&lt;P&gt;-Al&lt;/P&gt;</description><pubDate>Mon, 01 Aug 2005 10:57:00 GMT</pubDate><dc:creator>Al Heckers</dc:creator></item><item><title>RE: Quickly Moving Databases</title><link>http://www.sqlservercentral.com/Forums/Topic3193-75-1.aspx</link><description>&lt;P&gt;Not a bad article for what it covers, however, I've had experience with this sort of thing in the past and whilst I agree it's fine for small databases it is not the way to go with anything medium to large.&lt;/P&gt;&lt;P&gt;Also, if you have full-text indexing working against the database you should be aware that detaching it breaks the cataloging process, this applies even if you leave everything in situ and re-attach.  Again, whilst this isn't a concern for some smaller databases you will need to factor in the time required to do a full population after attaching it again.&lt;/P&gt;</description><pubDate>Mon, 01 Aug 2005 03:52:00 GMT</pubDate><dc:creator>Mike Metcalf-160221</dc:creator></item><item><title>RE: Quickly Moving Databases</title><link>http://www.sqlservercentral.com/Forums/Topic3193-75-1.aspx</link><description>&lt;P&gt;Good article but I have to agree with most of the folks out there&lt;/P&gt;&lt;P&gt;backup and restore is the way to go.&lt;/P&gt;&lt;P&gt;By the way how do you attach a database with more than one log file?&lt;/P&gt;&lt;P&gt;&lt;img src='images/emotions/blink.gif' height='20' width='20' border='0' title='Blink' align='absmiddle'&gt;&lt;/P&gt;</description><pubDate>Sun, 31 Jul 2005 22:15:00 GMT</pubDate><dc:creator>growl</dc:creator></item><item><title>RE: Quickly Moving Databases</title><link>http://www.sqlservercentral.com/Forums/Topic3193-75-1.aspx</link><description>&lt;P&gt;Great article Chris! (shows your attachment to the command line from an earlier life as an Oracle DBA, Mate!)&lt;/P&gt;&lt;P&gt;John Kanagaraj&lt;/P&gt;&lt;P&gt;(your friend from way back to '98 in Oracle-l)&lt;/P&gt;</description><pubDate>Fri, 29 Jul 2005 12:03:00 GMT</pubDate><dc:creator>John Kanagaraj</dc:creator></item><item><title>RE: Quickly Moving Databases</title><link>http://www.sqlservercentral.com/Forums/Topic3193-75-1.aspx</link><description>&lt;P&gt;What am I missing here???&lt;/P&gt;&lt;P&gt;I don't see that these techniques as good a simple backup and restore which has no downtime?&lt;/P&gt;&lt;P&gt;Where is the evidence that they are any faster?&lt;/P&gt;</description><pubDate>Fri, 29 Jul 2005 09:44:00 GMT</pubDate><dc:creator>JStiney</dc:creator></item><item><title>RE: Quickly Moving Databases</title><link>http://www.sqlservercentral.com/Forums/Topic3193-75-1.aspx</link><description>Great article! Very informative. Thanks so much for taking the time to write this up. As I am about to move a database myself, it's quite timely.One minor, even picky point: the term is actually "detach." There is no such word as "de-attach." http://dictionary.reference.com/search?q=detach</description><pubDate>Fri, 29 Jul 2005 09:27:00 GMT</pubDate><dc:creator>Merrill Aldrich</dc:creator></item><item><title>RE: Quickly Moving Databases</title><link>http://www.sqlservercentral.com/Forums/Topic3193-75-1.aspx</link><description>&lt;P&gt;nice article... I like the comment of "&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;articles I write will focus on the 'command line' (namely Query Analyser) to provide DBA’s with a reference point to turn back to when the GUI is not available for whatever reason."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;I'm old enuff to remember when this was Sybase, and it was ALL command line &lt;img src='images/emotions/cool.gif' height='20' width='20' border='0' title='Cool' align='absmiddle'&gt;&lt;/SPAN&gt;&lt;/P&gt;</description><pubDate>Wed, 18 May 2005 09:41:00 GMT</pubDate><dc:creator>Joe Burdette</dc:creator></item><item><title>RE: Quickly Moving Databases</title><link>http://www.sqlservercentral.com/Forums/Topic3193-75-1.aspx</link><description>&lt;P&gt;I would like to suggest that the article should have included you basic backup and restore as your first choice for moving databases.&lt;/P&gt;&lt;P&gt;There is no down time on your source system and I'm not sure that a detach, copy, and attach is that much faster than a backup and restore.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description><pubDate>Wed, 18 May 2005 08:01:00 GMT</pubDate><dc:creator>JStiney</dc:creator></item><item><title>RE: Quickly Moving Databases</title><link>http://www.sqlservercentral.com/Forums/Topic3193-75-1.aspx</link><description>&lt;P&gt;great article from Chris Kempster!&lt;/P&gt;&lt;P&gt;I like his approach of divide into 3 methods with t/sql code.&lt;/P&gt;&lt;P&gt;It is quite useful for my environment, since most files are &amp;lt; 2 gb due archiving periodically. &lt;/P&gt;&lt;P&gt;I did not know that there is a way to take a database off-line with [exec sp_dboption N'mydb', N'offline', N'true']. &lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;-D&lt;img src='images/emotions/smile.gif' height='20' width='20' border='0' title='Smile' align='absmiddle'&gt;&lt;/P&gt;</description><pubDate>Wed, 19 May 2004 10:41:00 GMT</pubDate><dc:creator>David Lu</dc:creator></item><item><title>RE: Quickly Moving Databases</title><link>http://www.sqlservercentral.com/Forums/Topic3193-75-1.aspx</link><description>&lt;P&gt;Nice article. I'd like to see more practical ones such as this.&lt;/P&gt;&lt;P&gt;One small point - timestamp. If you're moving tables between servers then you may get duplicate timestamp data when attaching. Timestamps are meant to be unique to a server.&lt;/P&gt;</description><pubDate>Wed, 19 May 2004 05:22:00 GMT</pubDate><dc:creator>Derek Robinson</dc:creator></item><item><title>RE: Quickly Moving Databases</title><link>http://www.sqlservercentral.com/Forums/Topic3193-75-1.aspx</link><description>Hi thereFrom memory here, I didnt "title" the article so the SSC crew gave it one :)Fair comment though, I have a few client sites that required 24x7, and attaching and de-attaching is not suitable.  To get around this we could:a)  replicate (can be complicated and you need to be 100% sure the schema is identicalb)  log ship (very fast)c)  script schema, read-only prod, and populate new server via linked server routines (no keys) the swap as need be at the business layer.CheersChris </description><pubDate>Thu, 23 May 2002 18:03:00 GMT</pubDate><dc:creator>ckempste</dc:creator></item><item><title>RE: Quickly Moving Databases</title><link>http://www.sqlservercentral.com/Forums/Topic3193-75-1.aspx</link><description>What kind of replication are you talking about? Sounds pretty much complicated. I consider the article's approach useful because of its simplicity. Not only the LAN may transfer a detached db. If the LAN is old and slow, an auxiliary removable hard disk or jazz unit also may transfer it, and the time saved would be considerable. &lt;BLOCKQUOTE id=quote&gt;&lt;font size=1 face="Verdana, Arial, Helvetica" id=quote&gt;quote:&lt;hr height=1 noshade id=quote&gt;I did like the article in general, although if I wanted a really fast method to transfer databases &amp;gt; 2 GB, I would not use this method.  sp_attach is a good way to transfer databases when downtime isn't the primary concern, although in the environment I work in, we would not be able to use it.  When we need to move a database from one server to the other with as little downtime as possible, we replicate as often as possible before the transfer.  Then we take the old server down after one last replication and restore it to the other server.  The setup for this process takes a long time, although we can get away with downtime less than 5 minutes.  With sp_attach, the file copy would take a long time. &lt;hr height=1 noshade id=quote&gt;&lt;/BLOCKQUOTE id=quote&gt;&lt;/font id=quote&gt;&lt;font face="Verdana, Arial, Helvetica" size=2 id=quote&gt; </description><pubDate>Thu, 23 May 2002 17:32:00 GMT</pubDate><dc:creator>Jorge Cordero</dc:creator></item><item><title>RE: Quickly Moving Databases</title><link>http://www.sqlservercentral.com/Forums/Topic3193-75-1.aspx</link><description>I did like the article in general, although if I wanted a really fast method to transfer databases &amp;gt; 2 GB, I would not use this method.  sp_attach is a good way to transfer databases when downtime isn't the primary concern, although in the environment I work in, we would not be able to use it.  When we need to move a database from one server to the other with as little downtime as possible, we replicate as often as possible before the transfer.  Then we take the old server down after one last replication and restore it to the other server.  The setup for this process takes a long time, although we can get away with downtime less than 5 minutes.  With sp_attach, the file copy would take a long time. </description><pubDate>Mon, 20 May 2002 18:00:00 GMT</pubDate><dc:creator>Strommy</dc:creator></item><item><title>Quickly Moving Databases</title><link>http://www.sqlservercentral.com/Forums/Topic3193-75-1.aspx</link><description>Comments posted to this topic are about the content posted at &lt;A HREF=http://www.sqlservercentral.com/columnists/ckempster/deattachandreattachdatabases.asp&gt;http://www.sqlservercentral.com/columnists/ckempster/deattachandreattachdatabases.asp&lt;/A&gt;</description><pubDate>Sat, 23 Mar 2002 00:00:00 GMT</pubDate><dc:creator>ckempste</dc:creator></item></channel></rss>
