Re: How to move tables between databases

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Keith Kratochvil (sqlguy.back2u_at_comcast.net)
Date: 09/15/04


Date: Wed, 15 Sep 2004 13:03:33 -0500

Use Enterprise Manager or Query Analyzer to create a CREATE TABLE script for
you. Create the table in the appropriate database. Use INSERT
INTO...SELECT to move the data

OR

SELECT *
INTO TheOtherDatabase.dbo.TheTable
FROM TheCurrentDatabase.dbo.TheTable

and then create the keys and indexes on the new table.

-- 
Keith
"Jeff Farquharson" <JeffFarquharson@discussions.microsoft.com> wrote in
message news:2FF36FD6-455A-415A-96F6-43312257CEE3@microsoft.com...
> I am in the process of re-organinzing several SQL Server databases so I
would
> like to move tables from one database to another.  I was hoping it would
be
> as simple as dragging the table from one DB to another in Enterprise
Manager,
> but no such luck.
>
> Is there an easy way to move tables between databases?
>
> Any help would be much appreciated.


Relevant Pages

  • Re: Automate DB update
    ... First of all there is nobody who can work with Query Analyzer. ... I just forgot that I can edit script in Query ... > correct database and specify dbo as the owner of objects. ... I send the script to my client as sql file. ...
    (microsoft.public.vb.general.discussion)
  • Re: Automate DB update
    ... First of all there is nobody who can work with Query Analyzer. ... I just forgot that I can edit script in Query ... > correct database and specify dbo as the owner of objects. ... I send the script to my client as sql file. ...
    (microsoft.public.sqlserver.programming)
  • Re: Automate DB update
    ... First of all there is nobody who can work with Query Analyzer. ... I just forgot that I can edit script in Query ... > correct database and specify dbo as the owner of objects. ... I send the script to my client as sql file. ...
    (microsoft.public.vb.database)
  • Re: Automate DB update
    ... First of all there is nobody who can work with Query Analyzer. ... I just forgot that I can edit script in Query ... > correct database and specify dbo as the owner of objects. ... I send the script to my client as sql file. ...
    (microsoft.public.vb.database.ado)
  • RE: Recreating a database???
    ... Unfortunately the script that Enterprise Manager produces doesn't always ... to build a database using the scripts you've created. ... record the build into a .SQL file and as the builder builds in the correct ...
    (microsoft.public.sqlserver.programming)