SQL Sever copy table

Posted on 2012-09-11
Last Modified: 2012-09-12
Hello Gurus

I would like to copy the contents of  1 table (customers) from DB1 to another table called also Customers in BD2.

Since I am not sure about the indexes and structures... I would like to export the content to a csv file or excel or whatever format... and then go to the DB2 and delete the contents of the Customers table and insert the exported data...

SQL 2008

Question by:ammounpierre
    LVL 23

    Accepted Solution

    As far as I understand your question, these are the ways that I came to mind now

    Option 1 - You can use query to copy contents between databases in a single server.

    INSERT INTO DB1.dbo.Customers SELECT * FROM DB2.dbo.Customers
    Before doing this truncate or delete the data from destination table if required.
    TRUNCATE TABLE DB2.dbo.Customers
    DELETE FROM DB2.dbo.Customers

    Option 2 - You can use import wizard to directly copy data to other database table or to an excel sheet.

    LVL 7

    Expert Comment

    I think You Can Use import - Export Wizard which is very easy to use

    Please right click on your one of database
    and than select task - > Import or Export Data
    than Please Select Proper Source and Destination Databases and Tables
    than Finish

    If you find any error than just check that error
    and go to Edit Mappings and Select ignore in case of Identity Column

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
    The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
    Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
    Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

    760 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

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now