RE: copying MS SQL tables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



yes, this is kind of what i want.  Using a web interface.  Thanks, i'll give it a shot.

--
Gerardo S. Rojas
mailto: grojas@xxxxxxxxxxxxxxxx


-----Original Message-----
From: Robert Twitty [mailto:rtwitty@xxxxxxxxxxxxxxxxx]
Sent: Wednesday, March 17, 2004 3:25 PM
To: Gerardo Rojas
Cc: php-windows@xxxxxxxxxxxxx
Subject: RE:  copying MS SQL tables


You can download the odbtp extension at http://odbtp.sourceforge.net, and
then do the something like the following:

<?php

    $FromTable = $_REQUEST['FromTable'];
    $ToTable   = $_REQUEST['ToTable'];

    $con1 = odbtp_connect( 'odbtp.somewhere.com',
                           'DRIVER={SQL Server};SERVER=server1;UID=uid1;PWD=pwd1;DATABASE=database1;' ) or die;

    $con2 = odbtp_connect( 'odbtp.somewhere.com',
                           'DRIVER={SQL Server};SERVER=server2;UID=uid2;PWD=pwd2;DATABASE=database2;' ) or die;

    $qry1 = odbtp_query( "SELECT * FROM $FromTable", $con1 ) or die;

    $qry2 = odbtp_allocate_query( $con2 ) or die;
    odbtp_set_cursor( $qry2, ODB_CURSOR_DYNAMIC ) or die;
    odbtp_query( "SELECT * FROM $ToTable", $qry2 ) or die;
    odbtp_fetch( $qry2 );

    $n_fields = odbtp_num_fields( $qry1 );

    while( $row = odbtp_fetch_row( $qry1 ) ) {
        for( $f = 0; $f < $n_fields; $f++ )
            odbtp_field( $qry2, $f, $row[$f] );
        odbtp_row_add( $qry2 ) or die;
    }
    odbtp_close( $con1 );
    odbtp_close( $con2 );

    echo "DONE!";
?>

It may not be as efficient as bcp, but I think it is what you want.

-- bob

On Wed, 17 Mar 2004, Gerardo Rojas wrote:

> Yes, i realize this.  (this requires, to many mouse clicks) But, what i want is to have it all hidden.  I select the remote server on a web page, give it a table and presto!  Table copied.
>
>
> --
> Gerardo S. Rojas
> mailto: grojas@xxxxxxxxxxxxxxxx
>
>
> -----Original Message-----
> From: Frank M. Kromann [mailto:frank@xxxxxxxxxxxx]
> Sent: Wednesday, March 17, 2004 1:14 PM
> To: Svensson, B.A.T. (HKG)
> Cc: 'php-windows@xxxxxxxxxxxxx'
> Subject: RE:  copying MS SQL tables
>
>
> If you install the MSSQL server Client tools on your PC you will be amle to
> use the Data Transformation Service (import/export) to copy data and
> structure from one SQL server to another. Thats the fastest way to do
> this.
>
> - Frank
>
> > How many rows do you have in the tables?
> >
> > If many  use bcp.exe to bulk copy out data form source server,
> > ftp the file to the other server and then bulk copy data into the
> > target server. That should be the fastets way if you have a lot
> > of data to copy.
> >
> > -----Original Message-----
> > From: Gerardo Rojas
> > To: php-windows@xxxxxxxxxxxxx
> > Sent: 17-3-2004 19:45
> > Subject:  copying MS SQL tables
> >
> > Is there a quick way to copy an entire table from one MSSQL server to
> > another using PHP.  These servers are accessed remotely.  I have all
> > required permissions.
> >
> >
> > --
> > Gerardo S. Rojas
> > mailto: grojas@xxxxxxxxxxxxxxxx
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux