Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #1014

Re: Moving a Database

Path csiph.com!usenet.pasdenom.info!news.albasani.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From Erland Sommarskog <esquel@sommarskog.se>
Newsgroups comp.databases.ms-sqlserver, microsoft.public.sqlserver.programming
Subject Re: Moving a Database
Followup-To comp.databases.ms-sqlserver
Date Thu, 3 May 2012 07:21:14 +0000 (UTC)
Organization Erland Sommarskog
Lines 30
Message-ID <XnsA0485F27DA332Yazorman@127.0.0.1> (permalink)
References <4km2q7dd1qb90j2c6tbjoj51oqhqklivhl@4ax.com> <4fa178d6$0$6990$e4fe514c@news2.news.xs4all.nl> <fv23q7l5ufuj1rdduvre8ckenl8hc9fima@4ax.com> <XnsA047F0F2DD8EBYazorman@127.0.0.1> <kht3q79a9v91p0tfu2710n0qh44778r1b2@4ax.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
Injection-Date Thu, 3 May 2012 07:21:14 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="G7+Jz22XqYCG8C6rb1H3YA"; logging-data="12080"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19p1VulCMX86n02pA2wsqQi"
User-Agent Xnews/2005.10.03 Mime-proxy/1.4.c.4 (Win32)
Cancel-Lock sha1:qcGnsgCijRGGizw/lKUwwNX6naE=
Xref csiph.com comp.databases.ms-sqlserver:1014

Cross-posted to 2 groups.

Followups directed to: comp.databases.ms-sqlserver

Show key headers only | View raw


Gene Wirchenko (genew@ocis.net) writes:
>      I want to be able to slurp the whole database so that I will be
> able to get a copy of the production data for debugging use.  On the
> current system, when there are problems, my boss may send a copy of
> the database with instructions to look at certain rows.  This makes it
> much easier to replicate trouble, and is not very difficult for him to
> do.
> 
>      So what is the best way of doing this?  I am getting conflicting
> data.
 
BACKUP DATABASE db TO DISK = '<somepath>' WITH INIT

RESTORE DATABASE db FROM DISK '<somepath>' WITH
   MOVE '<name1>' TO '<path.mdf>',
   MOVE '<name2>' TO '<path.ldf>',
   REPLACE

You find name1 and name2 by running sp_helpdb on the source database. You 
can also use one of RESTORE HEADERONLY or RESTORE FILELISTONLY. (I never 
remember which is which.) These are logical names for the database files.


-- 
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

Back to comp.databases.ms-sqlserver | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Moving a Database Gene Wirchenko <genew@ocis.net> - 2012-05-02 09:06 -0700
  Re: Moving a Database Jeroen Mostert <jmostert@xs4all.nl> - 2012-05-02 20:11 +0200
    Re: Moving a Database Jeroen Mostert <jmostert@xs4all.nl> - 2012-05-02 20:14 +0200
    Re: Moving a Database Gene Wirchenko <genew@ocis.net> - 2012-05-02 12:41 -0700
      Re: Moving a Database Erland Sommarskog <esquel@sommarskog.se> - 2012-05-02 23:41 +0200
        Re: Moving a Database Gene Wirchenko <genew@ocis.net> - 2012-05-02 20:10 -0700
          Re: Moving a Database Erland Sommarskog <esquel@sommarskog.se> - 2012-05-03 07:21 +0000
      Re: Moving a Database Mark D Powell <Mark.Powell2@hp.com> - 2012-05-03 07:29 -0700

csiph-web