Showing posts with label reside. Show all posts
Showing posts with label reside. Show all posts

Thursday, March 22, 2012

copying table from one database to another

I would like to copy a table from one database to another. These two
databases reside in two different servers/instances? Is this possible? If so,
how can I code it in m C++ application? Thanks!
You have 2 choices, Database solution or client based solution.
Database: Have your DBA create a linked server connection to server2 on
server1. Now you can execute this statement from server1
INSERT MyDest (column_list) SELECT column_list from
server2.mydb.dbo.MySource where ...
Client based solution:
Setup ADO connection to both servers. Populate a recordset from the source db
Iterate through this recordset and insert records in destination using a
procedure that has your insert logic.
HTH
Arun
"luv2travel" wrote:

> I would like to copy a table from one database to another. These two
> databases reside in two different servers/instances? Is this possible? If so,
> how can I code it in m C++ application? Thanks!

copying table from one database to another

I would like to copy a table from one database to another. These two
databases reside in two different servers/instances? Is this possible? If so,
how can I code it in m C++ application? Thanks!You have 2 choices, Database solution or client based solution.
Database: Have your DBA create a linked server connection to server2 on
server1. Now you can execute this statement from server1
INSERT MyDest (column_list) SELECT column_list from
server2.mydb.dbo.MySource where ...
Client based solution:
Setup ADO connection to both servers. Populate a recordset from the source db
Iterate through this recordset and insert records in destination using a
procedure that has your insert logic.
HTH
Arun
"luv2travel" wrote:
> I would like to copy a table from one database to another. These two
> databases reside in two different servers/instances? Is this possible? If so,
> how can I code it in m C++ application? Thanks!

copying table from one database to another

I would like to copy a table from one database to another. These two
databases reside in two different servers/instances? Is this possible? If so
,
how can I code it in m C++ application? Thanks!You have 2 choices, Database solution or client based solution.
Database: Have your DBA create a linked server connection to server2 on
server1. Now you can execute this statement from server1
INSERT MyDest (column_list) SELECT column_list from
server2.mydb.dbo.MySource where ...
Client based solution:
Setup ADO connection to both servers. Populate a recordset from the source d
b
Iterate through this recordset and insert records in destination using a
procedure that has your insert logic.
HTH
Arun
"luv2travel" wrote:

> I would like to copy a table from one database to another. These two
> databases reside in two different servers/instances? Is this possible? If
so,
> how can I code it in m C++ application? Thanks!

Tuesday, March 20, 2012

Copying one text column to another

Hi All
I have to copy text data from a table in one database to a table in a
different database, both table reside on the same server.
I tried two options which didn't work (see code below), and will be more
than gratefull for any help.
Thanks
Elie Grouchko
***************************************
I tried the following (didn't work):
UPDATE database2.dbo.table2
SET textcolumn2 = (SELECT database1.dbo.textcolumn1 FROM table1 WHERE
tablekey1 = @.tablekey1)
WHERE tablekey2 = @.tablekey2
***************************************
I also tried (also didn't work):
Select @.textcolumn1ptr = TextPtr(textcolumn1) FROM database1.dbo.table1
WHERE tablekey1 = @.tablekey1
Select @.textcolumn2ptr = TextPtr(textcolumn2) FROM database2.dbo.table2
WHERE tablekey2 = @.tablekey2
UpdateText
database2.dbo.table2.textcolumn2 @.textcolumn2ptr
Null
0
database1.dbo.table1.textcolumn1 @.textcolumn1ptrElie,
I think this will do what you want:
update database2.dbo.table2 set
textcolumn2 = T1.textcolumn1
from database1.dbo.table1 as T1
where T1.tablekey1 = database2.dbo.table2.tablekey2
and database2.dbo.table2.tablekey2 = @.tablekey2
Steve Kass
Drew University
Elie Grouchko wrote:

>Hi All
>I have to copy text data from a table in one database to a table in a
>different database, both table reside on the same server.
>I tried two options which didn't work (see code below), and will be more
>than gratefull for any help.
>Thanks
>Elie Grouchko
>***************************************
>I tried the following (didn't work):
> UPDATE database2.dbo.table2
> SET textcolumn2 = (SELECT database1.dbo.textcolumn1 FROM table1 WHERE
>tablekey1 = @.tablekey1)
> WHERE tablekey2 = @.tablekey2
>***************************************
>I also tried (also didn't work):
> Select @.textcolumn1ptr = TextPtr(textcolumn1) FROM database1.dbo.table1
> WHERE tablekey1 = @.tablekey1
> Select @.textcolumn2ptr = TextPtr(textcolumn2) FROM database2.dbo.table2
> WHERE tablekey2 = @.tablekey2
> UpdateText
> database2.dbo.table2.textcolumn2 @.textcolumn2ptr
> Null
> 0
> database1.dbo.table1.textcolumn1 @.textcolumn1ptr
>
>|||Great, it works
Thanks
:)
"Steve Kass" <skass@.drew.edu> wrote in message
news:%23V4SREbIFHA.2740@.TK2MSFTNGP12.phx.gbl...
> Elie,
> I think this will do what you want:
> update database2.dbo.table2 set
> textcolumn2 = T1.textcolumn1
> from database1.dbo.table1 as T1
> where T1.tablekey1 = database2.dbo.table2.tablekey2
> and database2.dbo.table2.tablekey2 = @.tablekey2
> Steve Kass
> Drew University
> Elie Grouchko wrote:
>sql