Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old November 3rd, 2004, 11:39 AM
spanishfly spanishfly is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 2 spanishfly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Angry How do I copy or move data from one table to another

OK Chaps.

Just been reading through the Forums and you all seem like a helpful bunch.

I have a problem, I know nothing really about SQL Queries.

I need to copy data from a table in one database (db1) to another table in another database (db2).

I have tried to familiarise my self with the commands and have come up with a few queries that I thought should work. But so far no real joy.

Each time I try to run the queries I receive an error messge that the Table already exists (this I know, I want the data copying into an existing table), I can however copy the data I need into a NEW table.....but that defeats the object really.

If anyone has a sample query that I can try and test it would be much appreciated.

Thanks for your time and efforts, look forward to a few replies.

Mike

Reply With Quote
  #2  
Old November 3rd, 2004, 12:49 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 19 m 36 sec
Reputation Power: 181
Going across databases will vary depending on the db you're using. (edit: never mind, this is the SQL Server forum, isn't it )

In SQL Server something like this should work if the table structures match

INSERT INTO db2..table SELECT * FROM db1..table
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Last edited by Doug G : November 3rd, 2004 at 12:52 PM.

Reply With Quote
  #3  
Old November 3rd, 2004, 01:11 PM
spanishfly spanishfly is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 2 spanishfly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by Doug G
Going across databases will vary depending on the db you're using. (edit: never mind, this is the SQL Server forum, isn't it )

In SQL Server something like this should work if the table structures match

INSERT INTO db2..table SELECT * FROM db1..table

Structures match. I think

Thankyou for your help, I really appreciate it. Although I am still running into trouble, in the example you have given me before you show how to state the database and tables that you want to use "db2..table" and "db1..table" can you explain to me what the two ".." represent, if anything.

And my apologies for my lameness.....but you got to ask haven't you.

Thanks in advance.

Reply With Quote
  #4  
Old November 3rd, 2004, 04:53 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 19 m 36 sec
Reputation Power: 181

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > How do I copy or move data from one table to another


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT