Solved

Copying  data from one table to another

Posted on 2008-06-25
6
691 Views
Last Modified: 2008-06-25
What is the best way to copy data from one table in a BD to another table in other DB.
the tables are not the same tables, so I will need to specify where the data from the source will go in the  new DB and in what field.

In my SQL Managment I have noth DB connected
0
Comment
Question by:Ennio
6 Comments
 
LVL 60

Expert Comment

by:chapmandew
Comment Utility
insert into sometable(fieldname1, fieldname2, fieldname3)
select fieldname1, fieldname2, fieldname3)
from someothertable
where somecriteria
0
 
LVL 1

Author Comment

by:Ennio
Comment Utility
But for example
someothertable is in another server not in the same server as sometable.
0
 
LVL 60

Assisted Solution

by:chapmandew
chapmandew earned 200 total points
Comment Utility
Ahh...you failed to mention that in your question.  :)  You're going to need to setup a linked server.

http://msdn.microsoft.com/en-us/library/aa213778(SQL.80).aspx

http://www.databasejournal.com/features/mssql/article.php/3085211
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 75

Assisted Solution

by:Aneesh Retnakaran
Aneesh Retnakaran earned 50 total points
Comment Utility
Hello Ennio,

you have to create a linked server first, then you can use the following syntax

insert into sometable(fieldname1, fieldname2, fieldname3)
select fieldname1, fieldname2, fieldname3)
from LinkedServerName.dbName..someothertable
where somecriteria


GOD Bless,
Aneesh R.
0
 
LVL 8

Accepted Solution

by:
DenverRick earned 250 total points
Comment Utility
Use the Export/Import function in SQL 2000 or 2005 they are both similar.  After creating the export and imports and setting mappings of the different fields you can save them to a Data Transformation Package and run them anytime you need to.
0
 
LVL 1

Author Comment

by:Ennio
Comment Utility
Using the export/import function worked great, and it was simple
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
What does "flush tables;" do exactly? 7 44
C# SQL BULK INSERT CLASS 5 32
Complex SQL 10 31
How to find duplicates in SQL Server 3 20
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.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

728 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

12 Experts available now in Live!

Get 1:1 Help Now