Extracting tables from one Database to another

  • I am working on a project and I need some help. The idea is to move two tables from an existing database to another database on the same server. I can use the DTS wizard to copy the tables over to the new database, but what else is required to complete the process as far as stored procedures and any others pointing at the existing database?

  • Are you looking to have all stored procedures in the original database (dbA) access the tables in the new databases (dbB) and the tables will be deleted from dbA?

    You need to manually point the procedures, views, functions, etc. to the new database. You can do this with four part naming (not recommended) by referencing the tables like this.

    insert into dbB.dbo.TableA

    The other way is to create a view in dbA that points to the table in dbB. So if the table being moved is Sales, then move it to dbB. Then run this

    create view Sales

    as

    select colA

    , colB

    ...

    from dbB.dbo.Sales

    and that way you don't need to update code.

  • Hi Thomas

    Why do you want to move two tables from database A to database B if you need to reference them with stored procedure from database A.

    If the data is part of the same system, keep them in the same database.

    What is the reason for your action?

    /Morten

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply