Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Remote Server Syntax

0 views
Skip to first unread message

scott

unread,
Sep 6, 2010, 7:05:37 PM9/6/10
to
I'm connected to a remote sql 2008 server. I will be running some update
queries from within mang. studio to update the remote server's db with data
from my local sql server.

What would the SELECT syntax look like to access the remote server?

My remote server has a hostname address called "db1.mydomain.com" and an ip
address of 87.111.100.2.

Would a select statement look like the below? The below syntax gives an
error saying"
The object name 'dbo.db1.mydomain.com.mydb.mytable contains more than the
maximum number of prefixes. The maximum is 3."


CODE:
==================

SELECT * from dbo.db1.mydomain.com.mydb.mytable


Jeffrey Williams

unread,
Sep 6, 2010, 9:17:47 PM9/6/10
to
There are several ways you can do this:

1) Use a linked server and access the table directly using 4-part naming
2) Use SSIS and build a package
3) Export to a file and import from the file

My preference would be to use SSIS and build a package that connects
directly to each instance. To use a linked server, you first have to create
the linked server - and then you can use a query like:

SELECT {columns}
FROM linkedservername.database.schema.table
WHERE {criteria};

Jeff

"scott" <sba...@mileslumber.com> wrote in message
news:#ya8FghT...@TK2MSFTNGP04.phx.gbl...

scott

unread,
Sep 7, 2010, 1:28:02 PM9/7/10
to
What does the below "double period" syntax refer to?

CODE:

Select * FROM Northwind..Categories


"Jeffrey Williams" <jeff.wil...@verizon.net> wrote in message
news:D2313A51-962F-4E6B...@microsoft.com...

Erland Sommarskog

unread,
Sep 7, 2010, 5:11:55 PM9/7/10
to
scott (sba...@mileslumber.com) writes:
> What does the below "double period" syntax refer to?
>
> CODE:
>
> Select * FROM Northwind..Categories

An object reference in SQL Server can have to up for components that
are separated by periods.

The leftmost component is the object. (For instance a table) This component
is mandatory.

The next component is the schema. A schema holds a group of objects, and
it's kind of a namespace. If you leave out the schema, the user's default
schema applies. It many cases this is the dbo schema.

The third component from the left is the database. If left out the
current database is implied.

The fourth component from the left is the server. Default is the local
server.

In the example above, database and table have been specified, but the
schema is left out. In practice this is the same as

Northwind..Catogories

But if your default schema in Northwind is Scott, and there is a
Northwind.Scott.Categories too, Northwind..Categories would resolve
to that table.

--
Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

Gene Wirchenko

unread,
Sep 7, 2010, 6:36:40 PM9/7/10
to
On Tue, 07 Sep 2010 23:11:55 +0200, Erland Sommarskog
<esq...@sommarskog.se> wrote:

>scott (sba...@mileslumber.com) writes:
>> What does the below "double period" syntax refer to?
>>
>> CODE:
>>
>> Select * FROM Northwind..Categories
>
>An object reference in SQL Server can have to up for components that
>are separated by periods.
>
>The leftmost component is the object. (For instance a table) This component

^^^^
>is mandatory.

>The next component is the schema. A schema holds a group of objects, and
>it's kind of a namespace. If you leave out the schema, the user's default
>schema applies. It many cases this is the dbo schema.
>
>The third component from the left is the database. If left out the

^^^^


>current database is implied.
>
>The fourth component from the left is the server. Default is the local

^^^^
>server.

I hope you meant "right" in each of the above cases.

>In the example above, database and table have been specified, but the
>schema is left out. In practice this is the same as
>
> Northwind..Catogories
>
>But if your default schema in Northwind is Scott, and there is a
>Northwind.Scott.Categories too, Northwind..Categories would resolve
>to that table.

Sincerely,

Gene Wirchenko

Erland Sommarskog

unread,
Sep 8, 2010, 3:30:20 AM9/8/10
to
Gene Wirchenko (ge...@ocis.net) writes:
> I hope you meant "right" in each of the above cases.

*Right* you are!

Thank for correct what I *left* out!


--
Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

0 new messages