 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Jose Guest
|
Posted: Fri Feb 04, 2005 11:50 am Post subject: Saving an ADO Result Set |
|
|
Hi,
I have to different servers with MSSQL 7 and i want to save in a new table
in the second server the result of a select query executed in the main
server. Is there a direct (and easy) way to do it?
Thanks for your help.
|
|
| Back to top |
|
 |
Heinrich Braun Guest
|
Posted: Fri Feb 04, 2005 9:04 pm Post subject: Re: Saving an ADO Result Set |
|
|
Hi,
an easy way is by linking a remote-server (may even be access/excel or
any other database-server):
--check "sp_addlinkedserverlogin" as well, you may need it, depending on
--user permissions
use master
go
-- CHECK IF REQUESTED SERVER(S) EXIST
if not exists (select * from master.dbo.sysservers where (srvname =
'MYSERVER2'))
begin
EXEC sp_addlinkedserver 'MYSERVER2', N'SQL Server'
end
--than do query with INTO
use mydatabase1
go
select * into MYSERVER2.dbo.mydatabse2.newtable from mytable1
--you may pack the serverlinking into a stored procedure
--thats it , you don't need an resultset first, just execute an ado
--command or query
hth
heinrich
Jose schrieb:
| Quote: | Hi,
I have to different servers with MSSQL 7 and i want to save in a new table
in the second server the result of a select query executed in the main
server. Is there a direct (and easy) way to do it?
Thanks for your help.
|
|
|
| Back to top |
|
 |
Jose Guest
|
Posted: Mon Feb 07, 2005 8:27 am Post subject: Re: Saving an ADO Result Set |
|
|
heinrich,
Thanks for the response. It was really helpful.
Jose.
|
|
| Back to top |
|
 |
Jose Guest
|
Posted: Mon Feb 07, 2005 2:55 pm Post subject: Re: Saving an ADO Result Set |
|
|
Hi Heinrich,
The query analyzer says that my object has too many prefixes...
"Heinrich Braun" <heinrich.braun (AT) homagSPAMM (DOT) de> escribió en el mensaje
news:4203e333$1 (AT) newsgroups (DOT) borland.com...
| Quote: | Hi,
an easy way is by linking a remote-server (may even be access/excel or
any other database-server):
--check "sp_addlinkedserverlogin" as well, you may need it, depending on
--user permissions
use master
go
-- CHECK IF REQUESTED SERVER(S) EXIST
if not exists (select * from master.dbo.sysservers where (srvname =
'MYSERVER2'))
begin
EXEC sp_addlinkedserver 'MYSERVER2', N'SQL Server'
end
--than do query with INTO
use mydatabase1
go
select * into MYSERVER2.dbo.mydatabse2.newtable from mytable1
--you may pack the serverlinking into a stored procedure
--thats it , you don't need an resultset first, just execute an ado
--command or query
hth
heinrich
Jose schrieb:
Hi,
I have to different servers with MSSQL 7 and i want to save in a new
table
in the second server the result of a select query executed in the main
server. Is there a direct (and easy) way to do it?
Thanks for your help.
|
|
|
| Back to top |
|
 |
Heinrich Braun Guest
|
Posted: Thu Feb 10, 2005 1:04 pm Post subject: Re: Saving an ADO Result Set |
|
|
Hi Jose,
sorry I was out of office for a few days.
can you post the sql-code, if your probelm still exists?
'Prefixes' is the servername.database.ower.table ...
you may spare it, if the commend 'use database' is used.
Heinrich
Jose schrieb:
| Quote: | Hi Heinrich,
The query analyzer says that my object has too many prefixes...
"Heinrich Braun" <heinrich.braun (AT) homagSPAMM (DOT) de> escribió en el mensaje
news:4203e333$1 (AT) newsgroups (DOT) borland.com...
Hi,
an easy way is by linking a remote-server (may even be access/excel or
any other database-server):
--check "sp_addlinkedserverlogin" as well, you may need it, depending on
--user permissions
use master
go
-- CHECK IF REQUESTED SERVER(S) EXIST
if not exists (select * from master.dbo.sysservers where (srvname =
'MYSERVER2'))
begin
EXEC sp_addlinkedserver 'MYSERVER2', N'SQL Server'
end
--than do query with INTO
use mydatabase1
go
select * into MYSERVER2.dbo.mydatabse2.newtable from mytable1
--you may pack the serverlinking into a stored procedure
--thats it , you don't need an resultset first, just execute an ado
--command or query
hth
heinrich
Jose schrieb:
Hi,
I have to different servers with MSSQL 7 and i want to save in a new
table
in the second server the result of a select query executed in the main
server. Is there a direct (and easy) way to do it?
Thanks for your help.
|
|
|
| Back to top |
|
 |
Heinrich Braun Guest
|
Posted: Thu Feb 10, 2005 2:20 pm Post subject: Re: Saving an ADO Result Set |
|
|
Hi Jose
select * into MYSERVER2.dbo.mydatabse2.newtable from mytable1
--is wrong, my fault :-(
select * into MYSERVER2.mydatabse2.dbo.newtable from mytable1
-- is the correct syntax!
Heinrich
Jose schrieb:
| Quote: | Hi Heinrich,
The query analyzer says that my object has too many prefixes...
"Heinrich Braun" <heinrich.braun (AT) homagSPAMM (DOT) de> escribió en el mensaje
news:4203e333$1 (AT) newsgroups (DOT) borland.com...
Hi,
an easy way is by linking a remote-server (may even be access/excel or
any other database-server):
--check "sp_addlinkedserverlogin" as well, you may need it, depending on
--user permissions
use master
go
-- CHECK IF REQUESTED SERVER(S) EXIST
if not exists (select * from master.dbo.sysservers where (srvname =
'MYSERVER2'))
begin
EXEC sp_addlinkedserver 'MYSERVER2', N'SQL Server'
end
--than do query with INTO
use mydatabase1
go
select * into MYSERVER2.dbo.mydatabse2.newtable from mytable1
--you may pack the serverlinking into a stored procedure
--thats it , you don't need an resultset first, just execute an ado
--command or query
hth
heinrich
Jose schrieb:
Hi,
I have to different servers with MSSQL 7 and i want to save in a new
table
in the second server the result of a select query executed in the main
server. Is there a direct (and easy) way to do it?
Thanks for your help.
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|