• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Moving tables between dbs as a scheduled event

Guest
Nov 15, 2006 Nov 15, 2006

Copy link to clipboard

Copied

Basically, I need a current user table in two databases, without having to add new users to two separate dbs.

I'm trying to set up a scheduled event that will delete the User table from database A, and copy a table of the same name from database B into database A. I'm assuming that since I'm using two separate databases that I can't use a stored procedure.

Anyone have any suggestions? I tried to use a DTS wizard to copy the contents of dbA.table into dbB.table, but it vomited on a primary key error.

TOPICS
Advanced techniques

Views

315

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 15, 2006 Nov 15, 2006

Copy link to clipboard

Copied

I have done this before in SQL Server 2000 Enterprise using database replication. You may want to google it to see if that would work for you.

Trevor
ColdFusion Tips

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 15, 2006 Nov 15, 2006

Copy link to clipboard

Copied

Also I don't see how it didn't work using DTS. The primary key should copy over fine as long as you drop and recreate the table before you start to copy the data over.

Trevor
Don't click here

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 15, 2006 Nov 15, 2006

Copy link to clipboard

Copied

Trevor -- I didn't drop and recreate the first time. The second time (just now, after your first post), I did drop and recreate -- only there are foreign key constraints. Is there a way to drop all FK constraints, drop table, recreate, and then recreate the FKs?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 15, 2006 Nov 15, 2006

Copy link to clipboard

Copied

Simpler, copy table from B to A with different name. Run two queries to update the real table in A. Then drop the table you just copied over.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 15, 2006 Nov 15, 2006

Copy link to clipboard

Copied

LATEST
Got it done! I did an import and choose "between two SQL databases," and that allowed me to import the keys along with the tables. I was able to schedule that to run every night at midnight, and in the even that someone can't wait that long, I can mess with them manually.

THANK YOU, guys. I'm a new CF developer, and I'm more than daunted by what I was left to work with.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation