Showing posts with label brackets. Show all posts
Showing posts with label brackets. Show all posts

Sunday, March 11, 2012

Connecting to another SQL Server Instance

For Server 'instance' names, becasue of the backslash '', you need to put t
he 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 wan
t. If future needs cause any changes in the database, you code is less likel
y 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-9
2E7-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 erro
r,
> Line 1: Incorrect syntax near ''. I tried removing the '' and then it
> indicated, Could not find server 'UMDPSMB7VSQLSERVERALT' in sysservers. I
s
> it possible to do this ?
>
> Code: Select * From UMDPSMB7V\SQLSERVERALT.dbo.Rmtest.Table1
>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|||For Server 'instance' names, becasue of the backslash '', you need to put t
he 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 wan
t. If future needs cause any changes in the database, you code is less likel
y 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-9
2E7-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 erro
r,
> Line 1: Incorrect syntax near ''. I tried removing the '' and then it
> indicated, Could not find server 'UMDPSMB7VSQLSERVERALT' in sysservers. I
s
> it possible to do this ?
>
> Code: Select * From UMDPSMB7V\SQLSERVERALT.dbo.Rmtest.Table1
>|||It worked. Thank you.
"Arnie Rowland" wrote:
[vbcol=seagreen]
> 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 w
ant. If future needs cause any changes in the database, you code is less lik
ely 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:B7
9703B6-DABD-4D7F-92E7-E7E056D66CA3@.microsoft.com...