Monday, March 26, 2012

Linked server name

Microsoft computer names can have hyphens in the name.
When I run Sp_Addlinkedserver 'server-name' it works fine.
When I try to use it in something like "Select * from
server-name.<dbName>.dbo.<tablename>" I get a sytax error
on the hyphen. anyone see this before? did all kinds of
searches in the KB and didn't see anthing.You'll need to use [ ] to surround your server name e.g.
select * from [server-name].<dbName>.dbo.<tablename>
--
HTH
Jasper Smith (SQL Server MVP)
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"Jim" <anonymous@.discussions.microsoft.com> wrote in message
news:041801c3d620$4216bdb0$a101280a@.phx.gbl...
> Microsoft computer names can have hyphens in the name.
> When I run Sp_Addlinkedserver 'server-name' it works fine.
> When I try to use it in something like "Select * from
> server-name.<dbName>.dbo.<tablename>" I get a sytax error
> on the hyphen. anyone see this before? did all kinds of
> searches in the KB and didn't see anthing.|||Does it help to enclose the server name in square
brackets? (i.e., [server-name].dbname.dbo.tablename)
Tim
>--Original Message--
>Microsoft computer names can have hyphens in the name.
>When I run Sp_Addlinkedserver 'server-name' it works
fine.
>When I try to use it in something like "Select * from
>server-name.<dbName>.dbo.<tablename>" I get a sytax
error
>on the hyphen. anyone see this before? did all kinds of
>searches in the KB and didn't see anthing.
>.
>|||>--Original Message--
>Does it help to enclose the server name in square
>brackets? (i.e., [server-name].dbname.dbo.tablename)
>Tim
>
>>--Original Message--
>>Microsoft computer names can have hyphens in the name.
>>When I run Sp_Addlinkedserver 'server-name' it works
>fine.
>>When I try to use it in something like "Select * from
>>server-name.<dbName>.dbo.<tablename>" I get a sytax
>error
>>on the hyphen. anyone see this before? did all kinds of
>>searches in the KB and didn't see anthing.
>>.
>.
>|||Thanks Guys that did it!
>--Original Message--
>Does it help to enclose the server name in square
>brackets? (i.e., [server-name].dbname.dbo.tablename)
>Tim
>
>>--Original Message--
>>Microsoft computer names can have hyphens in the name.
>>When I run Sp_Addlinkedserver 'server-name' it works
>fine.
>>When I try to use it in something like "Select * from
>>server-name.<dbName>.dbo.<tablename>" I get a sytax
>error
>>on the hyphen. anyone see this before? did all kinds of
>>searches in the KB and didn't see anthing.
>>.
>.
>

No comments:

Post a Comment