Sunday, March 11, 2012

Connecting to another SQL Server Instance

I created another instance of SQL Server and am trying to access a table on
it from the other server. I set up the code listed below and got the error,
Line 1: Incorrect syntax near '\'. I tried removing the '\' and then it
indicated, Could not find server 'UMDPSMB7VSQLSERVERALT' in sysservers. Is
it possible to do this ?
Code: Select * From UMDPSMB7V\SQLSERVERALT.dbo.Rmtest.Table1This is a multi-part message in MIME format.
--=_NextPart_000_06FD_01C69CE1.737BB6A0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: quoted-printable
For Server 'instance' names, becasue of the backslash '\', you need to =put the server\instance name in square brackets. For example:
Select Column1
, Column2
, etc. From [UMDPSMB7V\SQLSERVERALT].dbo.Rmtest.Table1
Note: It's bad form to use SELECT *. Much better to list the columns you =want. If future needs cause any changes in the database, you code is =less likely to 'break'.
-- Arnie Rowland, YACE* "To be successful, your heart must accompany your knowledge."
*Yet Another Certification Exam
"rmcompute" <rmcompute@.discussions.microsoft.com> wrote in message =news:B79703B6-DABD-4D7F-92E7-E7E056D66CA3@.microsoft.com...
>I created another instance of SQL Server and am trying to access a =table on > it from the other server. I set up the code listed below and got the =error, > Line 1: Incorrect syntax near '\'. I tried removing the '\' and then =it > indicated, Could not find server 'UMDPSMB7VSQLSERVERALT' in =sysservers. Is > it possible to do this ?
> > Code: Select * From UMDPSMB7V\SQLSERVERALT.dbo.Rmtest.Table1
>
--=_NextPart_000_06FD_01C69CE1.737BB6A0
Content-Type: text/html;
charset="Utf-8"
Content-Transfer-Encoding: quoted-printable
=EF=BB=BF<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

For Server 'instance' names, becasue of =the backslash '\', you need to put the server\instance name in square =brackets. For example:
Select
Column1
, =Column2
, etc. =From [UMDPSMB7V\SQLSERVERALT].dbo.Rmtest.Table1
Note: It's bad form to use SELECT *. =Much better to list the columns you want. If future needs cause any changes in the =database, you code is less likely to 'break'.
-- Arnie Rowland, YACE* "To =be successful, your heart must accompany your knowledge."
*Yet Another Certification =Exam
"rmcompute" wrote in message news:B79703B6-DABD-4D7F-92E7-E7E056D66CA3@.microsoft.com...>I =created another instance of SQL Server and am trying to access a table on > it =from the other server. I set up the code listed below and got the error, => Line 1: Incorrect syntax near '\'. I tried removing the '\' and =then it > indicated, Could not find server 'UMDPSMB7VSQLSERVERALT' in sysservers. Is > it possible to do this ?> > Code: Select * From UMDPSMB7V\SQLSERVERALT.dbo.Rmtest.Table1>

--=_NextPart_000_06FD_01C69CE1.737BB6A0--|||It worked. Thank you.
"Arnie Rowland" wrote:
> For Server 'instance' names, becasue of the backslash '\', you need to put the server\instance name in square brackets. For example:
> Select
> Column1
> , Column2
> , etc.
> From [UMDPSMB7V\SQLSERVERALT].dbo.Rmtest.Table1
> Note: It's bad form to use SELECT *. Much better to list the columns you want. If future needs cause any changes in the database, you code is less likely to 'break'.
>
> --
> Arnie Rowland, YACE*
> "To be successful, your heart must accompany your knowledge."
> *Yet Another Certification Exam
>
> "rmcompute" <rmcompute@.discussions.microsoft.com> wrote in message news:B79703B6-DABD-4D7F-92E7-E7E056D66CA3@.microsoft.com...
> >I created another instance of SQL Server and am trying to access a table on
> > it from the other server. I set up the code listed below and got the error,
> > Line 1: Incorrect syntax near '\'. I tried removing the '\' and then it
> > indicated, Could not find server 'UMDPSMB7VSQLSERVERALT' in sysservers. Is
> > it possible to do this ?
> >
> > Code: Select * From UMDPSMB7V\SQLSERVERALT.dbo.Rmtest

No comments:

Post a Comment