Вопрос

I need to move a series of tables from one datasource to another. Our hosting company doesn't give shared passwords amongst the databases so I can't write a SQL script to handle it.

The best option is just writing a little coldfusion scripty that takes care of it.

Ordinarily I would do something like: SELECT * INTO database.table FROM database.table

The only problem with this is that cfquery's don't allow you to use two datasources in the same query.

I don't think I could use a QoQ's either because you can't tell it to use the second datasource, but to have a dbType of 'Query'.

Can anyone think of any intelligent ways of getting this done? Or is the only option to just loop over each line in the first query adding them individually to the second?

My problem with that is that it will take much longer. We have a lot of tables to move.

Это было полезно?

Решение

Ok, so you don't have a shared password between the databases, but you do seem to have the passwords for each individual database (since you have datasources set up). So, can you create a linked server definition from database 1 to database 2? User credentials can be saved against the linked server, so they don't have to be the same as the source DB. Once that's set up, you can definitely move data between the two DBs.

We use this all the time to sync data from our live database into our test environment. I can provide more specific SQL if this would work for you.

Другие советы

You CAN access two databases, but not two datasources in the same query.

I wrote something a few years ago called "DataSynch" for just this sort of thing.

http://www.bryantwebconsulting.com/blog/index.cfm/2006/9/20/database_synchronization

Everything you need for this to work is included in my free "com.sebtools" package: http://sebtools.riaforge.org/

I haven't actually used this in a few years, but I can't think of any reason why it wouldn't still work.

Henry - why do any of this? Why not just use SQL manager to move over the selected tables usign the "import data" function? (right click on your dB and choose "import" - then use the native client and permissions for the "other" database to specify the tables. Your SQL manager will need to have access to both DBs, but the db servers themselves do not need access to each other. Your manager studio will serve as a conduit.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top