issuing sql command that references 2 database servers

  • Thread starter Thread starter cj
  • Start date Start date
C

cj

I'm tryin to set up a sqlcommand in VB.NET that would issue the command:
insert into server1.database.owner.table select * from
server2.database.owner.table
Since this sqlcommand has it's connection property set to a connection
string for server1 I'm assuming it isn't seeing server2 -- I get invalid
object name server2.

How can I get one sql statement to reference multiple servers?
 
Hi Cj,

Welcome to MSDN newsgroup.
Regarding on the Sql command question ou mentioned, based on my experience,
for executing two sql statement which refernece to table in different
databases, we have to separate them into two SqlCommand objects and
executing them separately... The ADO.NET's SqlCommand is associated with
a certain SqlConnection(a certain database..), so for the two sqlcommand ,
we have to create two sqlconnection instances for them....

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)







--------------------
| Date: Thu, 01 Dec 2005 16:07:31 -0500
| From: cj <[email protected]>
| User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)
| X-Accept-Language: en-us, en
| MIME-Version: 1.0
| Subject: issuing sql command that references 2 database servers
| Content-Type: text/plain; charset=ISO-8859-1; format=flowed
| Content-Transfer-Encoding: 7bit
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.vb
| NNTP-Posting-Host: 208.254.170.98
| Lines: 1
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.languages.vb:306864
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| I'm tryin to set up a sqlcommand in VB.NET that would issue the command:
| insert into server1.database.owner.table select * from
| server2.database.owner.table
| Since this sqlcommand has it's connection property set to a connection
| string for server1 I'm assuming it isn't seeing server2 -- I get invalid
| object name server2.
|
| How can I get one sql statement to reference multiple servers?
|
 
Thank you for your reply. I believe you are correct. I'd hoped there
was a way but didn't really expect to find on. If it was two tables in
two different databases on the SAME SERVER I think it would work but
like you said since a sqlcommand is associated with one particular
sqlconnection it can't see more than one server at a time.

I expect I'll have to load them from one server into a dataset then out
to the new server. Unless anyone has any better ideas.
 
Thanks for your followup CJ,

Yes, so far to have to use the mutiple connection/commands approach is
there're tables in different database/server which will be processed at the
same time...

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| Date: Fri, 02 Dec 2005 08:39:18 -0500
| From: cj <[email protected]>
| User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)
| X-Accept-Language: en-us, en
| MIME-Version: 1.0
| Subject: Re: issuing sql command that references 2 database servers
| References: <[email protected]>
<[email protected]>
| In-Reply-To: <[email protected]>
| Content-Type: text/plain; charset=ISO-8859-1; format=flowed
| Content-Transfer-Encoding: 7bit
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.vb
| NNTP-Posting-Host: 208.254.170.98
| Lines: 1
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.languages.vb:306951
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| Thank you for your reply. I believe you are correct. I'd hoped there
| was a way but didn't really expect to find on. If it was two tables in
| two different databases on the SAME SERVER I think it would work but
| like you said since a sqlcommand is associated with one particular
| sqlconnection it can't see more than one server at a time.
|
| I expect I'll have to load them from one server into a dataset then out
| to the new server. Unless anyone has any better ideas.
|
|
| Steven Cheng[MSFT] wrote:
| > Hi Cj,
| >
| > Welcome to MSDN newsgroup.
| > Regarding on the Sql command question ou mentioned, based on my
experience,
| > for executing two sql statement which refernece to table in different
| > databases, we have to separate them into two SqlCommand objects and
| > executing them separately... The ADO.NET's SqlCommand is associated
with
| > a certain SqlConnection(a certain database..), so for the two
sqlcommand ,
| > we have to create two sqlconnection instances for them....
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| >
| >
| >
| >
| >
| > --------------------
| > | Date: Thu, 01 Dec 2005 16:07:31 -0500
| > | From: cj <[email protected]>
| > | User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)
| > | X-Accept-Language: en-us, en
| > | MIME-Version: 1.0
| > | Subject: issuing sql command that references 2 database servers
| > | Content-Type: text/plain; charset=ISO-8859-1; format=flowed
| > | Content-Transfer-Encoding: 7bit
| > | Message-ID: <[email protected]>
| > | Newsgroups: microsoft.public.dotnet.languages.vb
| > | NNTP-Posting-Host: 208.254.170.98
| > | Lines: 1
| > | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
| > | Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.languages.vb:306864
| > | X-Tomcat-NG: microsoft.public.dotnet.languages.vb
| > |
| > | I'm tryin to set up a sqlcommand in VB.NET that would issue the
command:
| > | insert into server1.database.owner.table select * from
| > | server2.database.owner.table
| > | Since this sqlcommand has it's connection property set to a
connection
| > | string for server1 I'm assuming it isn't seeing server2 -- I get
invalid
| > | object name server2.
| > |
| > | How can I get one sql statement to reference multiple servers?
| > |
| >
|
 
Can I do this?

MyOdbcAdapter.Fill(MyDs, "recent_calls")
SqlDataAdapter1.Update(MyDs, "recent_calls")
MyDs.Tables("recent_calls").Clear()
SqlDataAdapter1.Fill(MyDs, "recent_calls")
DataGrid1.DataSource = MyDs.Tables("recent_calls")
 
Can I do this?

MyOdbcAdapter.Fill(MyDs, "recent_calls")
SqlDataAdapter1.Update(MyDs, "recent_calls")
MyDs.Tables("recent_calls").Clear()
SqlDataAdapter1.Fill(MyDs, "recent_calls")
DataGrid1.DataSource = MyDs.Tables("recent_calls")

Thanks for your followup CJ,

Yes, so far to have to use the mutiple connection/commands approach is
there're tables in different database/server which will be processed at the
same time...

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| Date: Fri, 02 Dec 2005 08:39:18 -0500
| From: cj <[email protected]>
| User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)
| X-Accept-Language: en-us, en
| MIME-Version: 1.0
| Subject: Re: issuing sql command that references 2 database servers
| References: <[email protected]>
<[email protected]>
| In-Reply-To: <[email protected]>
| Content-Type: text/plain; charset=ISO-8859-1; format=flowed
| Content-Transfer-Encoding: 7bit
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.vb
| NNTP-Posting-Host: 208.254.170.98
| Lines: 1
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.languages.vb:306951
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| Thank you for your reply. I believe you are correct. I'd hoped there
| was a way but didn't really expect to find on. If it was two tables in
| two different databases on the SAME SERVER I think it would work but
| like you said since a sqlcommand is associated with one particular
| sqlconnection it can't see more than one server at a time.
|
| I expect I'll have to load them from one server into a dataset then out
| to the new server. Unless anyone has any better ideas.
|
|
| Steven Cheng[MSFT] wrote:
| > Hi Cj,
| >
| > Welcome to MSDN newsgroup.
| > Regarding on the Sql command question ou mentioned, based on my
experience,
| > for executing two sql statement which refernece to table in different
| > databases, we have to separate them into two SqlCommand objects and
| > executing them separately... The ADO.NET's SqlCommand is associated
with
| > a certain SqlConnection(a certain database..), so for the two
sqlcommand ,
| > we have to create two sqlconnection instances for them....
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| >
| >
| >
| >
| >
| > --------------------
| > | Date: Thu, 01 Dec 2005 16:07:31 -0500
| > | From: cj <[email protected]>
| > | User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)
| > | X-Accept-Language: en-us, en
| > | MIME-Version: 1.0
| > | Subject: issuing sql command that references 2 database servers
| > | Content-Type: text/plain; charset=ISO-8859-1; format=flowed
| > | Content-Transfer-Encoding: 7bit
| > | Message-ID: <[email protected]>
| > | Newsgroups: microsoft.public.dotnet.languages.vb
| > | NNTP-Posting-Host: 208.254.170.98
| > | Lines: 1
| > | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
| > | Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.languages.vb:306864
| > | X-Tomcat-NG: microsoft.public.dotnet.languages.vb
| > |
| > | I'm tryin to set up a sqlcommand in VB.NET that would issue the
command:
| > | insert into server1.database.owner.table select * from
| > | server2.database.owner.table
| > | Since this sqlcommand has it's connection property set to a
connection
| > | string for server1 I'm assuming it isn't seeing server2 -- I get
invalid
| > | object name server2.
| > |
| > | How can I get one sql statement to reference multiple servers?
| > |
| >
|
 
Thanks for your followup Salam,

Yes, you can use two different DataAdapters to fill two different DataTable
(from different database....) in to the same DataSet instances... DataSet
is not bound to a certain connection... And when calling the
DataAdapter.Fill method, just specify the datatable's name you want to fill.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



--------------------
| Date: Mon, 05 Dec 2005 10:35:14 -0500
| From: cj <[email protected]>
| User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)
| X-Accept-Language: en-us, en
| MIME-Version: 1.0
| Subject: Re: issuing sql command that references 2 database servers
| References: <[email protected]>
<[email protected]>
<#[email protected]>
<7oW1z9T#[email protected]>
| In-Reply-To: <7oW1z9T#[email protected]>
| Content-Type: text/plain; charset=ISO-8859-1; format=flowed
| Content-Transfer-Encoding: 7bit
| Message-ID: <eeMl9Fb#[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.vb
| NNTP-Posting-Host: 208.254.170.98
| Lines: 1
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.languages.vb:307248
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| Can I do this?
|
| MyOdbcAdapter.Fill(MyDs, "recent_calls")
| SqlDataAdapter1.Update(MyDs, "recent_calls")
| MyDs.Tables("recent_calls").Clear()
| SqlDataAdapter1.Fill(MyDs, "recent_calls")
| DataGrid1.DataSource = MyDs.Tables("recent_calls")
|
|
| Steven Cheng[MSFT] wrote:
| > Thanks for your followup CJ,
| >
| > Yes, so far to have to use the mutiple connection/commands approach is
| > there're tables in different database/server which will be processed at
the
| > same time...
| >
| > Regards,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| > --------------------
| > | Date: Fri, 02 Dec 2005 08:39:18 -0500
| > | From: cj <[email protected]>
| > | User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)
| > | X-Accept-Language: en-us, en
| > | MIME-Version: 1.0
| > | Subject: Re: issuing sql command that references 2 database servers
| > | References: <[email protected]>
| > <[email protected]>
| > | In-Reply-To: <[email protected]>
| > | Content-Type: text/plain; charset=ISO-8859-1; format=flowed
| > | Content-Transfer-Encoding: 7bit
| > | Message-ID: <#[email protected]>
| > | Newsgroups: microsoft.public.dotnet.languages.vb
| > | NNTP-Posting-Host: 208.254.170.98
| > | Lines: 1
| > | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| > | Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.languages.vb:306951
| > | X-Tomcat-NG: microsoft.public.dotnet.languages.vb
| > |
| > | Thank you for your reply. I believe you are correct. I'd hoped
there
| > | was a way but didn't really expect to find on. If it was two tables
in
| > | two different databases on the SAME SERVER I think it would work but
| > | like you said since a sqlcommand is associated with one particular
| > | sqlconnection it can't see more than one server at a time.
| > |
| > | I expect I'll have to load them from one server into a dataset then
out
| > | to the new server. Unless anyone has any better ideas.
| > |
| > |
| > | Steven Cheng[MSFT] wrote:
| > | > Hi Cj,
| > | >
| > | > Welcome to MSDN newsgroup.
| > | > Regarding on the Sql command question ou mentioned, based on my
| > experience,
| > | > for executing two sql statement which refernece to table in
different
| > | > databases, we have to separate them into two SqlCommand objects and
| > | > executing them separately... The ADO.NET's SqlCommand is
associated
| > with
| > | > a certain SqlConnection(a certain database..), so for the two
| > sqlcommand ,
| > | > we have to create two sqlconnection instances for them....
| > | >
| > | > Thanks,
| > | >
| > | > Steven Cheng
| > | > Microsoft Online Support
| > | >
| > | > Get Secure! www.microsoft.com/security
| > | > (This posting is provided "AS IS", with no warranties, and confers
no
| > | > rights.)
| > | >
| > | >
| > | >
| > | >
| > | >
| > | >
| > | >
| > | > --------------------
| > | > | Date: Thu, 01 Dec 2005 16:07:31 -0500
| > | > | From: cj <[email protected]>
| > | > | User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)
| > | > | X-Accept-Language: en-us, en
| > | > | MIME-Version: 1.0
| > | > | Subject: issuing sql command that references 2 database servers
| > | > | Content-Type: text/plain; charset=ISO-8859-1; format=flowed
| > | > | Content-Transfer-Encoding: 7bit
| > | > | Message-ID: <[email protected]>
| > | > | Newsgroups: microsoft.public.dotnet.languages.vb
| > | > | NNTP-Posting-Host: 208.254.170.98
| > | > | Lines: 1
| > | > | Path:
TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
| > | > | Xref: TK2MSFTNGXA02.phx.gbl
| > microsoft.public.dotnet.languages.vb:306864
| > | > | X-Tomcat-NG: microsoft.public.dotnet.languages.vb
| > | > |
| > | > | I'm tryin to set up a sqlcommand in VB.NET that would issue the
| > command:
| > | > | insert into server1.database.owner.table select * from
| > | > | server2.database.owner.table
| > | > | Since this sqlcommand has it's connection property set to a
| > connection
| > | > | string for server1 I'm assuming it isn't seeing server2 -- I get
| > invalid
| > | > | object name server2.
| > | > |
| > | > | How can I get one sql statement to reference multiple servers?
| > | > |
| > | >
| > |
| >
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top