0

I have linked from one SQL Server to a remote SQL Server from within SSMS and from a new Query window can now successfully select data from the remote server using SQL like this;

SELECT * FROM [Server\Instance].Database.dbo.Table

But when I paste the above SQL into a View, SSMS removes the '[' and ']' from the server specification to give;

SELECT * FROM Server\Instance.Database.dbo.Table

and then returns the error: "Incorrect syntax near '\'".

How can I stop SSMS from removing the '[' and ']'?

I have overcome this problem before but cannot remember how! I even have working examples of Views but do not know how they retain their braces?

If there is a setting in Tools, Options I cannot find it. If there is a setting in the View definition I cannot find it :-(

Any help appreciated,

Cheers, Mal.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

0

I phoned a friend who suggested creating the view in this way;

CREATE VIEW [MyView] AS SELECT * FROM [Server\Instance].Database.dbo.Table

I could then successfully select from the view with;

SELECT * FROM [MyView]

I have not tried opening the view in the editor in case it strips the '[' and ']' out.

Mal.

Dharman
  • 30,962
  • 25
  • 85
  • 135